-2 c#
我有.xml扩展名的文件.使用C#我必须用另一个扩展名打开文件,例如.exe.我可以手动打开"打开方式"选项打开文件.现在我必须使用C#做同样的事情.我怎么做?
我猜你的问题是你想用你指定的任何程序使用C#打开一个文件.
您必须将该文件作为可支持文件类型的进程的参数启动:
Process process = new Process();
process.StartInfo.FileName = "SomeApplication.exe"; // The app to "Open With..."
process.StartInfo.Arguments = "'C:\\YourFile.xml'"; // The file to open
process.Start();
Run Code Online (Sandbox Code Playgroud)