473,670 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get current working path in C#.net

2 New Member
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" 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 99642
Ripendra007
27 New Member
store the path that u got by application.sta rtupPath 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 New Member
bina,
you can use simply path=@"\bin\deb ug";
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.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" 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
strandberg
2 New Member
...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\Lo cal Settings\Applic ation Data\Temporary Projects\Consol eApplication1\b in\Debug'
updated cwd is 'C:\Documents and Settings\per\Lo cal Settings\Applic ation Data\Temporary Projects\Consol eApplication1'

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
Rathorevivek
17 New Member
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" 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.Applica tionPath + @''/your folder/");

Regards,
Vivek Rathore
Mar 21 '07 #5
spriyasenthil
9 New Member
Hi,
I m new in c#.net . In C#.net, how i will get the current working path? when i used following function "Application.St artupPath" then it show the executable path.(e:\Projec t\DataList\bin\ debug). But i have created my project at the project directory. Now i want to get the path (e:\Project\Dat aList\). How i will get this? IS there any solution to solve this problem? I have created my crystal report file in the "e:\Project\Dat aList\" 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.AppDomai n.CurrentDomain .BaseDirectory;

or else

sAppPath = Environment.Cur rentDirectory;

try this out!

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

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

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

Similar topics

4
6176
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 get the path ...and save it, (in a cookie or in MySQL ). $ReturnUrl = $_SERVER.'?'.$_SERVER;
6
5390
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 I'm being stupid... Thanks,
1
13690
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 it is not a type of *.aspx.cs. I try to use System.Environment.CurrentDirectory() but it return c:\winnt\system32 when I use System.Web.HttpContext.Current.Server.MapPath("") it returns path from the aspx file that call the class method.
10
16910
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
1084
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
1568
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 standard library but was prevented by a python file with the same name in current working directory (but there was no __init__.py). Can I use some warning switch to print a warning on stdout? Thanks, Sunpreet.
4
3678
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 where I am storing the file - not what I would have expected. I would have expected it to be the same directory as the dir with my code - I guess I was wrong because thats not what is happening. On my own computer it wasn't a big problem...
14
13538
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 this code fragment: .... char otherpath; char cmd;
3
8229
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 will change the current working directory to the directory which include the script, so my script cannot find the data file. I think this is the problem of emacs because when I start pdb from console directly, it will not change current...
0
8388
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8817
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...
0
8663
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7423
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 project—planning, coding, testing, and deployment—without 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...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1799
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.