0

hi all, how can i start any application from c sharp
i mean for example, if i have an openfiledialog and the user opened it and selected any file and opened it, i need this file to opened in its application whatever its extension and its default start application.
i have googled and found that Process.Start takes the file name and its application but i don't know what is the type of the file the user is going o open
thanks in advance for any replies.

4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by gladiator1919
0

Process.start() will run an application. But if you pass to it a document. like a .jpg it will open in whatever its default application is. for example passing "http://www.dianiweb.com" would open your default web browser and navigate it to daniweb.

if you want to control the application that opens said doument, you can create a process object, and set its startinfo property to the document, and pass the program to run it in into its start method.

0

System.Diagnostics.Process.Start() will open anything(thats valid), in its default application.

but if u want to know the type of the file, u will have to get the extention of the file -- System.IO.Path.GetExtension(string Path)

.doc = document
.mp3 = ....
well u can figure out what im sayin

-1

hi all, how can i start any application from c sharp
i mean for example, if i have an openfiledialog and the user opened it and selected any file and opened it, i need this file to opened in its application whatever its extension and its default start application.
i have googled and found that Process.Start takes the file name and its application but i don't know what is the type of the file the user is going o open
thanks in advance for any replies.

hi...
first of all in proces.start method you need to pass two parameter
like you want to open IE then
process.start("iexplorer.exe","www.google.com");
it will run internet explorer and default page is google...

now according to your requirement you need to set filters for you application....
like which kind of files you want user to play....
like if jpg,jpeg,png,bmp...etc then windowfax viewer....
if .wmv,mpg,mpeg,flv,3gp..etc then for instace vlc...

using flter you get the extension of file selected...and using if condition you can play that.....
ex.. if(path.getExtension(openfiledialog1.filename)==".mpg")
process.start("vlc.exe",openfiledialog1.filename);

then problem solved

0

Thanks alot fro reply
i tried System.Diagnostics.Process.Start(fileName); and it worked perfect

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.