[英]C# - Process.Start()
I want to open test.txt.我想打开 test.txt。 In the previous project, I opened it with code below, but in the new project, nothing happened.
在之前的项目中,我用下面的代码打开了它,但是在新的项目中,什么都没有发生。 I tried many other solutions but nothing...
我尝试了许多其他解决方案,但没有...
static void Main(string[] args) {
string path = @"C:\\Users\\SB-Darjan\\Desktop\\Loader\\MG30\\MG30\\test.txt";
Process.Start(path);
}
When you use @ symbol with path then you should use single backslash.当您在路径中使用 @ 符号时,您应该使用单个反斜杠。
static void Main(string[] args)
{
string path = @"C:\Users\SB-
Darjan\Desktop\Loader\MG30\MG30\test.txt";
Process.Start("notepad.exe", path);
}
To solve your problem, you can use the same instruction but adding the exe you want to use to open your file as shown below.要解决您的问题,您可以使用相同的指令,但添加要用于打开文件的 exe,如下所示。
Process.Start("notepad.exe", @"C:\Users\SB-Darjan\Desktop\Loader\MG30\MG30\test.txt");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.