I am using a very short C# console app to launch an executable written in python, so that I can take advantage of click-once deployment.
In debug mode I am able to locate the two executable files that are included as resources. However, once the App is published I cannot seem to locate their relative file paths. I get an exception: "system cannot find the file specified"
using System;
using System.Diagnostics;
namespace UpdateConsole
{
class Program
{
static void Main(string[] args)
{
string RunningPath = AppDomain.CurrentDomain.BaseDirectory;
string driver_path = string.Format("{0}Resources\\chromedriver.exe", System.IO.Path.GetFullPath(System.IO.Path.Combine(RunningPath, @"")));
string exe_path = string.Format("{0}Resources\\DUU.exe", System.IO.Path.GetFullPath(System.IO.Path.Combine(RunningPath, @"")));
Process.Start(exe_path,driver_path);
}
}
}
I have also tried to reference the resource like so:
Properties.Resources.DUU;
But this returns a byte[] object and I am not sure how to extract a relative file path from here.
string RunningPath = AppDomain.CurrentDomain.BaseDirectory;
the file path provided by this code changes based on the build mode: 1. In debug mode it is.../bin/Debug. 2. In release mode it is.../bin/Release.
So make sure you copy the.exe files to the appropriate folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.