[英]How do I use Process.Start with a path which is in a label?
I am using 我在用
Process.Start(@"lbl_path.Text");
With and without quotes, but, it doesn't seem to work. 有和没有引号,但是,它似乎不起作用。 I added using System.Diagnostics;
我using System.Diagnostics;
添加using System.Diagnostics;
The text contained in lbl_Path
will be in constant change, that is why I'm not typing the path in after the '@' lbl_Path
包含的文本将保持不变,这就是为什么我不在'@'之后键入路径的原因
This passes a constant string: 这将传递一个常量字符串:
Process.Start(@"lbl_path.Text");
This passes the Text property of the lbl_path Label: 这将传递lbl_path标签的Text属性:
Process.Start(lbl_path.Text);
This escapes the \\ characters from the Text of the Label and passes it: 这将从标签的文本中转义\\字符并将其传递:
Process.Start(lbl_path.Text.Replace("\\", "\\\\");
// or
Process.Start(lbl_path.Text.Replace(@"\", @"\\");
这将是更合适的转义方式+使用标签中的字符串。
Process.Start(lbl_path.Text.Replace(@"\", @"\\"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.