473,915 Members | 4,307 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 99704
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
6190
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
5406
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
13701
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
16928
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
1094
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
1587
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
3690
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
13614
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
8248
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
10039
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9883
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
11359
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10928
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
11069
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
10543
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...
1
4779
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
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
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.