开发者

Open a file with other extension using C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

I have file with .xml extension.开发者_Go百科 Using C# i have to open the file with another extension, like .exe for example. I can open the file with the 'Open With' option manually. Now I have to do the same using C#. How do I do that?


I'm guessing your question is that you want to open a File using C# with any program you specify.

You'll have to launch the file as an argument of a process that can support the file type:

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();


string xmlname = "c:\\test.xml";    
string exename = System.IO.Path.ChangeExtension(xmlname, "exe");

I reread your question. I think you want to start the application with the Process.Start() method.


Visual Studio's default editor for other file extensions is set in Tools | Options | Text Editor | File Extensions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜