Windows should know where to find the file, so you need to somehow indicate that:
Or using the absolute path:
Process.Start("C:\\1.txt");
Or set the current directory:
Environment.CurrentDirectory = "C:\\"; Process.Start("1.txt");
Typically, CurrentDirectory set to executable.
[change]
If the file is in the same directory as the executable, you can use the following code:
var directory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var file = Path.Combine(directory, "1.txt"); Process.Start(file);
Alex aza
source share