472,119 Members | 1,308 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 99236
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

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.