0

I know there are plenty of questions about this topic but I reviewed them and I couldn't find what I need.

I need to run an exe in VB.Net but that exe needs some files that are in the exe's folder. When I try to run the exe using Shell or Process.Start() the exe looks for those files in my app folder (and throws an error) instead of the exe original folder. I can't move my app exe nor the external exe.

1
  • Are you refering to running a program from Visual Studio for debugging or running the final compiled exe in a real deployement? What files are you talking about? Commented Sep 28, 2014 at 18:39

2 Answers 2

4

Have you tried Directory.SetCurrentDirectory Method ? It sets the application's current working directory to the specified directory. change the example below with the path of the application you want to execute prior calling it.

Imports System
Imports System.IO

Directory.SetCurrentDirectory("C:\test")
Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory())
'Execute an application from C:\test

Output :

Current directory: C:\test
Sign up to request clarification or add additional context in comments.

Comments

0

You might be able to use the Windows startup path:

exePath = System.Windows.Forms.Application.StartupPath

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.