473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,395 developers and data experts.

How can i get the current directory of Project folder?

My project name ImageProfiler. My project is in the drive C: then how can i get the path of my project.. the output looks like this "C:\ImageProfiler"
Oct 25 '11 #1
1 43230
arie
64
I don't know why you need your project path, usually what people ned is the path to the directory where currently executing .exe file is. You do it like this:
Expand|Select|Wrap|Line Numbers
  1. string dirname = Directory.GetCurrentDirectory();
Then, I suppose to get your project directory, you'll need to call Directory.GetParent() a few times (depending on your project's file structure).

Other ways to find your exe directory are:

Expand|Select|Wrap|Line Numbers
  1. string appPath = Path.GetDirectoryName(Application.ExecutablePath);
  2.  
for Form applications and

Expand|Select|Wrap|Line Numbers
  1. string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(MyClass)).CodeBase);
for loaded assemblies (.exe, .dll).
You'll need to add certain references to your project to use those, like:

Expand|Select|Wrap|Line Numbers
  1. using System.IO;
  2. using System.Reflection;//in the lase example
Oct 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tomek | last post by:
Hello. How to get path to current directory and put this path to object of class String? I found FileSystemView.getHomeDirectory() but it returns path to home directory for example: ...
4
by: Jon Rea | last post by:
Hi, Just a quickie ... I thought that Directory.GetCurrentGirectory(), unless the current directory had been changed by the program, would always point to the directory where the .exe for the...
3
by: Alur | last post by:
Changing the current directory with the help of dialog window(MFC app) We can change directory with the help of the following code: CFileDialog m_ldFile(TRUE);...
5
by: astroboy | last post by:
How do I get project folder in .NET?
1
by: JIM.H. | last post by:
Hello, I work both home and work and I need to move my project folder from on server another. Each time I copy over files and try to debug the code it says “unable to start debugger on the...
3
by: Progman | last post by:
I use Visual Studio 2005 When I run msgbox Curdir(), I get the visual studio directory. This problem seems to be only in the VB part. In the ASP, we use ~/etc... to access files. Why I...
5
by: Killer42 | last post by:
Hi all. Is there any way to tell Access 2003 (and/or 2000) to default to the current directory where I started it? Every time I open a database and go to do an Import or whatever, the damned thing...
3
by: Mark Poppers | last post by:
I found a *.sln and an *.suo file which belong to my current project because the have the same name "TestDatabase33....." as my project. What is the purpose of these files ? If I delete them...
0
by: Renatebhp | last post by:
While using CurDir to get the current path where my open workbook is located, I get a result that's short of the current folder.e.g. the path to the file is...
8
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.