C# CF: How to open specific file extension with my program RRS feed

  • Question

  • Hi, Im developing a mobile application in dot net Compact framework. I managed to edit the registry HKEY_CLASSES_ROOT so that a click on file with .xyz extension will open my application. basically, i need to do some operation on this file when it's clicked.

    however, i realise that if i do that the first time, it reaches program.cs at static void Main. but when the program is running and i click on the file with .xyz extension again, it doesnt loads the programstatic void Main. i tried setting breakpoints at the form that is currently running but still nothing.

    so where does it go to? how can i detect file .xyz is clicked and do something??

    Saturday, March 13, 2010 12:04 PM

All replies

  • did you change the static void Main() method to
    static void Main(string[] args)
    Application.Run(new Form1());
    notice the signature of the Main method. explaination in case you didn't: the args parameter will contain the file name that the user want's to open (including the path), it's like executing your application with parameters. so if the user clicks the file "\storage card\folder1\file.xyz" your application will be executed as "MyApplication.exe \storage card\folder1\file.xyz" and you can get the file name by accessing the element 0 of the args array
    string FileName = args[0];
    make sure you check for the parameter availablility before you try to query it. use args.getUpperBound().


    Hope this helps.


    If you find my post helpful, please market as an answer or vote for it. Visit our community, http://www.windowsPhoneME.com

    • Proposed as answer by AdelAlzubeir Monday, April 5, 2010 6:29 PM
    Sunday, April 4, 2010 1:48 AM