I am working on a c# program that needs to be compatible with Windows and Linux (Mono).
I am trying to create a symbolic link in both platforms and I am using ProcessStartInfo in order for this to work. I haven't tried this on Linux yet but on Windows I am using the following code
ProcessStartInfo process = new ProcessStartInfo();
process.CreateNoWindow = true;
process.UseShellExecute = false;
process.FileName = "mklink";
process.WindowStyle = ProcessWindowStyle.Hidden;
process.Arguments = "/D " + webFolder + "MyFolder" + webFolder + "MyFolder_" + version;
Process.Start(process);
When I run the above code I get
System.ComponentModel.Win32Exception: The system cannot find the file specified
If I run mklink in command prompt it works fine.
I've had a look on Google and it says about doing a [DllImport("kernel32.dll")] but this isn't going to work on Linux.
Thanks for any help you can provide.
mklink
is a command of the cmd.exe
program, not a stand-alone program.
To run mklink
, you have to actually invoke cmd.exe
with an appropriate set of parameters, like this:
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c mklink " + argumentsForMklink);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With