Click here to Skip to main content
15,898,875 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi dears
I programmed a video player in c#.
this program is trying to read "*.KMPC" files.
in my program I should define the file path and the file name. For example @"c:/MyVideoFile.kmpc"
Now I have to rename all my files in copy that file into Drive "C" and after that Run the program.
I want to overcome this issue and modify my program. I want if I double-click in my fine with any name in any Drive My program will enable to recognize the file path and file name.
Please help me
Posted
Comments
karthik Udhayakumar 28-May-14 6:51am    
What have you tried so far?where is your code and where you are stuck up?

It's a 2-step process to get that done.
1) tell your OS to pass the file to your program
2) make your program capable of handling the OS call

1) Right-click on one of the video files,
choose "Open with >" and
"Choose standard application"
Search the file system for your program

2) OS calls your program with the file as a command-line parameter.
You can access that parameter via the GetCommandLineArgs method.
In your software, check if there is a valid filename in that argument list and if there is, play that file instead of the hard-coded one.

For a more sophisticated command line parser, have a look at C#/.NET Command Line Argument Parser Reloaded
 
Share this answer
 
 
Share this answer
 
Comments
alireza ghasemi 28-May-14 7:07am    
Hi Dear Richard MacCutchan
I knew that class. But I want some thing more than that. I want when my Program are close after I clikced on my file atumatically the program understands the file path and file name that I clicked on it.
For example when somebody clicked on mp3 Files the MWplayer will open and will play that file.
Vincent Beek 28-May-14 7:41am    
You will have to create a mimetype, where you assosiate the .kpmc files with your program.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900