473,803 Members | 3,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the path of current process ?

How do I find the full path where my current process is executed from?
System.Environm ent.CurrentDire ctory and
System.IO.Direc tory.GetCurrent Directory is not good enough because they may
be changed any many circumstance and not reflect the original location the
current process is started from.

Any Idea?
----------
Thanks
Sharon
May 10 '06 #1
2 13567
Ok, I found the how to:

System.Reflecti on.Assembly ass =
System.Reflecti on.Assembly.Get ExecutingAssemb ly();
string fullProcessPath = ass.Location;
string desiredDir = Path.GetDirecto ryName(fullProc essPath);
May 10 '06 #2
Hi,

In the Assembly class you have several properties you can use for this. take
a look at Location and/or CodeBase

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Sharon" <Sh*****@newsgr oups.nospam> wrote in message
news:AF******** *************** ***********@mic rosoft.com...
How do I find the full path where my current process is executed from?
System.Environm ent.CurrentDire ctory and
System.IO.Direc tory.GetCurrent Directory is not good enough because they
may
be changed any many circumstance and not reflect the original location the
current process is started from.

Any Idea?
----------
Thanks
Sharon

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3783
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ---------------------------------------------------------------------------- ---- Access to the path "CreateFolder" is denied.
70
4123
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the Python standard library, and Reinhold Birkenfeld started a discussion on it in python-dev <http://mail.python.org/pipermail/python-dev/2005-June/054438.html>. The upshot of the discussion was that many python-dev'ers wanted path added to the...
11
15314
by: kk | last post by:
Can any function tell the compiled program executing path? after using the program to open a file from MFC dialog box, the path changes. thks in advance.
0
1137
by: nic | last post by:
What is the best place to retrieve the current path of the aspx page being viewed? I want to store the current page path so after I perform some process I can return the user to where they were. It looks like I can get this info from a number of places and I was curious if there was a standard? ie. Request.Path Request.RawUrl etc...
10
3078
by: mirandacascade | last post by:
O/S: Win2K Vsn of Python:2.4 Based on a search of other posts in this group, it appears as though os.environ is one way to obtain the PATH environment variable. My questions: 1) is it correct that os.environ contains the PATH environment variable? 2) are there other ways to obtain the PATH environment variable? if so,
3
7966
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images C:\Inetpub\wwwroot\RunReportASP is the directory of my virtual directory for my app. In it's properties I did check "Write" as a permission. What else do I need to do?
1
1352
by: André | last post by:
I'm attempting to override a wxHtmlWindow method in order to pre-process the file before displaying it. I'm using a unicode version of wxPython. I don't think my problem are wxPython-specific, but rather a unicode mis-understanding. Consider the following: .. def OnLinkClicked(self, linkinfo): .. #adapted from the wxPython demo .. target_file = linkinfo.GetHref() .. current = self.GetOpenedPage() .. ...
12
8604
by: =?ISO-8859-1?Q?Thomas_B=F8rlum?= | last post by:
Hey all, I'm writing a c++ program that needs to read a file. I'm trying to read a file that is in the same directory as the executable. Everything works fine if I execute the program while in the program's directory. What I need to do is read that file regardless of where (cwd) I execute the program from, without hardcoding the absolute since the program might be moved or be in differant locations on other computers.
4
1972
by: Python | last post by:
Hi there, I moved a few modules into the modules folder (on OSX: /opt/local/lib/ python2.5/site-packages/). They don't show up though when I start IDLE... Is there a way to reload the modules folders in sys.path without logging out and back in? something like "source .cshrc" in a shell...
0
9564
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
10546
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
10310
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
10292
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
10068
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
9121
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...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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

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.