开发者

c# - Opening chosen file with associated App

I have successfully prompted user to select a file in C# using

the openFileDialog control.

I now have the filen开发者_C百科ame, lets call it foo.docx

I want to open the file with the asssoicated app.

i.e., if it is a docx file, launch with word.

Is there a best way to just pass the filename and it do the launch ?

I used System.Diagnostics.Process.Start(openFileDialog1.FileName.ToString());

TIA.

Ralph


Simply use

Process.Start(filename);

This will open the program in the default program set in Windows.

Also, you can use the same to open a URL in the user's default browser.


Just call Process.Start with the file name - the OS will select the associated application.

Process.Start(@"path to\foo.exe");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜