-3

I have file with .xml extension. 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?

Mizipzor
  • 51,151
  • 22
  • 97
  • 138
Vinod GH
  • 1
  • 1
  • 2
    Wait. Are you trying to open a binary (.exe) file in Visual Studio? I dont think that will do you any good. I think you need to rephrase the question (I tried to clean it up a little but couldnt figure out what you mean). – Mizipzor Jul 06 '10 at 08:56

3 Answers3

5

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();
djdd87
  • 67,346
  • 27
  • 156
  • 195
1
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.

codymanix
  • 28,510
  • 21
  • 92
  • 151
0

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

Richard
  • 106,783
  • 21
  • 203
  • 265