473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 99533
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

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

Similar topics

4
by: Sims | last post by:
Hi, I have a few 'secure' area where the user needs to log-in b4 they can make view it. I know how to redirect them to the login page but how can I return them to the page they were? if I...
6
by: Shaun Heveron | last post by:
Hi, I'm working on a portable ANSI C++ application designed to compile and execute under Windows and LINUX/UNIX. Is there a portable way of obtaining the current working directory? Sorry, if...
1
by: Chung | last post by:
Hi, I am developing an asp.net application. I have create some class method and I would like to get the folder path of that class method. I cannot use this.Mappath("") to get the path because...
10
by: farmer | last post by:
Request.Path will get the current Path name with file name such as: /Personal/Items.aspx How can I get the only Path name such as: /Personal
0
by: Roshawn Dawson | last post by:
Hi, I have a web application that has various sub directories. Here is what it looks like: MyApp/default.aspx MyApp/Author/default.aspx MyApp/xslt/books.xsl
2
by: ssjassal | last post by:
Is there a way to instruct Python to import modules from standard library even if there is one with the same name in the current working directory? I was trying to import BaseHTTPServer.py from...
4
by: Jeff | last post by:
I feel like I should have been able to figure this out but I can't seem to find any references on this topic. It seems like my current working directory is consistently a few directories up from...
14
by: gio | last post by:
I have a problem and the solution should works under windows and unix OS. Suppose I have a program ex.c in the directory X (so the current working directory of ex.c is X). Also suppose I have...
3
by: duyanning | last post by:
I have written a pyhton script that will process data file in current working directory. My script is in an different directory to data file. When I debug this script using pdb within emacs, emacs...
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.