我不需要任何类型的界面。我只需要该程序是一个打开目录(例如 F:)的 .exe
文件。
我会在 C# 中使用哪种模板? Visual Studio 以外的东西会更好吗?完全不同的过程会更好吗?
最佳答案
在 C#
中你可以这样做:
Process.Start(@"c:\users\");
当文件夹不存在时,此行将抛出 Win32Exception
。如果您使用 Process.Start("explorer.exe", @"C:\folder\");
它只会打开另一个文件夹(如果您指定的文件夹不存在)。
因此,如果您想仅打开文件夹,您应该这样做:
try
{
Process.Start(@"c:\users22222\");
}
catch (Win32Exception win32Exception)
{
//The system cannot find the file specified...
Console.WriteLine(win32Exception.Message);
}
关于c# - 如何在 Windows 资源管理器中打开文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32395163/