Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

VB.NET How to get DirectoryPath of running process?

How can i get the DirectoryPath of running process? not my application...
Another application that is running...
process module property filename https://docs.microsoft.com/en-us/dotnet/...work-4.7.2
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
Code
Dim x As Process() = Process.GetProcessesByName("TEST")
Dim modulepath As String
modulepath = x(0).MainModule.FileName
(Mar 3, 2019 11:04 AM)Vexallus Wrote:  
Code
Dim x As Process() = Process.GetProcessesByName("TEST")
Dim modulepath As String
modulepath = x(0).MainModule.FileName

It gives me the path + filename.exe

folder/folder/file.exe

I just need folder/folder
(Mar 3, 2019 11:45 AM)Formula 1 Wrote:  It gives me the path + filename.exe

folder/folder/file.exe

I just need folder/folder

you can use .Replace which will output the folder without the file name
(Mar 3, 2019 11:45 AM)Formula 1 Wrote:  It gives me the path + filename.exe

folder/folder/file.exe

I just need folder/folder

Code
Dim allPath As String = "C:\Windows\explorer.exe"

MsgBox(IO.Path.GetFileName(allPath)) 'Return "explorer.exe"

MsgBox(IO.Path.GetExtension(allPath)) 'Return ".exe"

MsgBox(IO.Path.GetFileNameWithoutExtension(allPath)) 'Return "explorer"

MsgBox(IO.Path.GetDirectoryName(allPath)) 'Return "C:\Windows"

MsgBox(IO.Path.GetFullPath(allPath)) 'Return "C:\Windows\explorer.exe"
Thank you guys for replying, it works fine


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by gigajewNov 17, 2019 11:47 AM 17 1,542 Nov 17, 2019 11:47 AM
Last Post: gigajew
[.NET] by BapeZOct 1, 2018 01:09 PM 5 274 Oct 1, 2018 01:09 PM
Last Post: oxidebuffalo
[C] by chrizatorJul 22, 2018 05:09 AM 4 229 Jul 22, 2018 05:09 AM
Last Post: Anzee