473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i get the current directory of Project folder?

16 New Member
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:\ImageProfil er"
Oct 25 '11 #1
1 45057
arie
64 New Member
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.GetPa rent() 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
87837
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: C:\Documments and Settings\Thomas Thanks for help.
4
16386
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 program was. However, if my program is launched from the start menu in windows XP, Directory.GetCurrentGirectory() returns a special windows directory for the user in "Documents and Settings" under c:\. As i want to open files that are in the...
3
3417
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); m_ldFile.m_ofn.lpstrInitialDir="c:\\"; // the initial folder. //below the dialog window is opened, then tfolders and eventually a file and after automatically current directory is changed . if(m_ldFile.DoModal()==IDOK) { //below finding out the path....
5
7752
by: astroboy | last post by:
How do I get project folder in .NET?
1
1386
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 server”. If I create a new project and import all the files to this project I am able to debug without problem. What is problem? Thanks,
3
8671
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 dont get my project directory?
5
5741
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 starts in My Documents. I don't think the "default database folder" option is likely to be any use, unless there's some way to set it dynamically to point to the current (or "working") folder. Not crucial, of course, just very annoying.
3
21086
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 accidentially: Are they re-created automatically ? Why are they currently not in the project folder (where the *.csproj file is) but in the parant folder ? Can I simply move them to the project folder ?
0
1482
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 C:\FolderLv1\FolderLv2\FolderLv3\Myfile.xls And CurDir returns: C:\FolderLv1\FolderLv2 This creates a problem when trying to open the next xls file in the same folder. Can anyone help? Here is the code: Private Sub ConsolidationButton_Click()
8
5215
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)... I recently put the following script online: <script type="text/javascript"><!-- function playmedia(mediafile) { newwindow=window.open(); if (window.focus) {newwindow.focus()} newwindow.document.write('<html>');
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.