C# 更改扩展名后打开文件
我想在更改扩展名后打开文件。扩展名已更改,但找不到要打开的文件,因此如何查找? 到目前为止,我所拥有的:C# 更改扩展名后打开文件,c#,C#,我想在更改扩展名后打开文件。扩展名已更改,但找不到要打开的文件,因此如何查找? 到目前为止,我所拥有的: filePath = openFileDialog.FileName; File.Move(filePath, Path.ChangeExtension(filePath, ".csv")); FileStream stream = File.Open(filePath, FileMode.Open); 使用Path.ChangeExtension的返回值: 上面的代码打开应用程序中的文件
filePath = openFileDialog.FileName;
File.Move(filePath, Path.ChangeExtension(filePath, ".csv"));
FileStream stream = File.Open(filePath, FileMode.Open);
使用Path.ChangeExtension的返回值:
上面的代码打开应用程序中的文件
如果希望Windows Shell使用Excel、OpenOffice等打开文件,除其他方法外,还可以这样做
System.Diagnostics.Process.Start(newFilePath);
扩展名已更改,但文件未更改open@MichelFaraday你能说得更具体点吗?是的。最初选择文件时,会进行转换,但不会在Excel中打开,这正是我试图打开的。修复!非常感谢。
System.Diagnostics.Process.Start(newFilePath);