Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In Vb.net I used the below code instead of sending the file path in the process.start().Because while giving the file path directly File explorer also opening with that file,I don't want to open file explorer.

Example: There are two application: App1 and app2.I am calling the app2 in app1.In the app2 I need to give the path of app1 with giving the app path directly.In app2 the file path of app1 needs to take automatically.So I can use the app2 in some other application whenever I needs.

What I have tried:

Dim path1 As String = System.AppDomain.CurrentDomain.BaseDirectory
Dim path2 As String = System.IO.Directory.GetCurrentDirectory
Dim path3 As String = System.Reflection.Assembly.GetExecutingAssembly.Location
Dim path3 As String = System.Reflection.Assembly.GetExecutingAssembly.CodeBase
Process.Start(path3)

If I used path1 or path2 in the process,file explorer also opening only particular file needs to open.
I used path3 in that particular file is opening but its opening continuously even after closing the application also.
Posted
Updated 7-Sep-22 18:54pm

1 solution

Paths 1 and 2 return a folder path, not a file: so when you use Process.Start they can only open File Explorer, not an application.

Path 3 returns the current executing file (normally an EXE file), and so when you try to run it, it will execute the current program again. If it's a DLL, then it's not an executable file so Process.Start will open File Explorer unless some other app is configured in Windows to open DLLs when you double click them.

So when the app runs the same app unless there is something in your code to prevent it doing it on the second execution you are going to fill the available memory with instances pretty quickly ...

What are you trying to do that you think this is a good idea?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900