Cant open file with associated app
I created an app. I have some files which I need to open with this app. So I made the association with the commands below:
a开发者_Go百科ssoc .bengi=BengiFile
ftype BengiFile="C:\Program Files (x86)\Bengi\CreateAS.exe" "%1" %*
After these, I can see that my file's icon has changed according to my app's icon. But when I double-click on it, the app is not opened. Can you tell what is wrong?
Thanks in advance.
EDIT:
to get the path of the file, I added the folowing code into main function in Python script:
if (len(sys.argv) > 1):
print sys.argv[1]
When I try to run it manually from command prompt, there is no problem: The app is run, and I can get the file path correctly. However, When I double click on a .bengi file, I get error:
Any suggestions?
Thanks a lot.
You need to add code in your application startup (main
method) to parse the command line arguments and open the file.
I suggest reading about this topic here.
This would normally look like:
static void Main(string[] args)
{
// parse args, do something with them (like open the file specified)
}
精彩评论