469,341 Members | 7,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,341 developers. It's quick & easy.

How to get current working path in C#.net

2
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.StartupPath" then it show the executable path.(e:\Project\DataList\bin\debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\DataList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\DataList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

With regards
Bina
Mar 9 '07 #1
6 98630
store the path that u got by application.startupPath in string variable like test
then split that path using the function split('/') and stored in to another variable and use

Bye hav a nice time
Mar 9 '07 #2
rac19
3
bina,
you can use simply path=@"\bin\debug";
by default the application directory will be the project directory


Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.StartupPath" then it show the executable path.(e:\Project\DataList\bin\debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\DataList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\DataList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

With regards
Bina
Mar 9 '07 #3
...how i will get the current working path
Is this what you are looking for?

Expand|Select|Wrap|Line Numbers
  1. string cwd = System.IO.Directory.GetCurrentDirectory();
  2.     Console.WriteLine("cwd is '{0}'", cwd);
  3.  
  4.     if (cwd.EndsWith("\\bin\\Debug"))
  5.     {
  6.       cwd = cwd.Replace("\\bin\\Debug", "");
  7.       Console.WriteLine("updated cwd is '{0}'", cwd);
  8.     }
  9.  
For me the output is:
cwd is 'C:\Documents and Settings\per\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\bin\Debug'
updated cwd is 'C:\Documents and Settings\per\Local Settings\Application Data\Temporary Projects\ConsoleApplication1'

HTH,
Per
--
Per Erik Strandberg

Home: http://www.pererikstrandberg.se/blog/ .
Optimization in C# and Visual Basic .NET: http://tomopt.com/tomnet/ .
Mar 14 '07 #4
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.StartupPath" then it show the executable path.(e:\Project\DataList\bin\debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\DataList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\DataList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

With regards
Bina
Hi Bina,
Try out this
Server.MapPath(Request.ApplicationPath + @''/your folder/");

Regards,
Vivek Rathore
Mar 21 '07 #5
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.StartupPath" then it show the executable path.(e:\Project\DataList\bin\debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\DataList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\DataList\" directory. How i will get the path when i will create installation file? Is there any solution to solve this problem? Please help me about this. Is there anybody who can help me?

With regards
Bina

hi

may be this will help u

sPath = System.AppDomain.CurrentDomain.BaseDirectory;

or else

sAppPath = Environment.CurrentDirectory;

try this out!

Rdgs,
Priya.S.
Mar 21 '07 #6
Simply use (..) for parent directory ...

i.e.
string rptpath = Application.StartupPath() + @"\..\..\";
Dec 14 '12 #7

Post your reply

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

Similar topics

1 post views Thread by Chung | last post: by
reply views Thread by Roshawn Dawson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.