Application path
How to get path of file(ex:test.txt) currently running in c#.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 7, 2012, 10:32 AM EDT
However, to get the file path you would need to get its handle and use that to fish it out of kernel memory which would require the use of a driver. This can be done in C/C++ but would be very difficult from managed code which can only run in user mode.
If you don't mind a bit of C++, then I'd check this article:
http://www.codeproject.com/Articles/18975/Listing-Used-Files
SenthilkumarRank #387 · 6.5K reputationPosted Apr 7, 2012, 12:34 AM EDT
You can get all the files which are currently running in the operating system.
If you get the file name then you can get the path.
foreach (Process p in Process.GetProcesses())
To get the current application execution path,
http://www.csharp-examples.net/get-application-directory/
brunda kRank #3,804 · 389 reputationPosted Apr 7, 2012, 1:27 AM EDT
say i have Test.txt file running(open) then thru the above code i am getting
Process notepad: C:\Windows\system32\NOTEPAD.EXE.
But my requirment is to get
Application Name: Test.txt
Path of Application : c:/Tempfolder
Sam HobbsRank #107 · 20.5K reputationPosted Apr 7, 2012, 5:11 PM EDT
brunda kRank #3,804 · 389 reputationPosted Apr 7, 2012, 6:27 PM EDT