-2

I have created a setup file for c# application. In which i created a shortcut for the application and when installed the shortcut will be added in desktop. But my application has to launch either files drag into the shortcut or double click on it.. But drag files to shortcut is not working.

Other than that i was thinking about the possiblity of installing the .exe directly to deskyop. But in that case also supporting files need to be added in the desktop which is not a good way.

Any suggesions are most welcome.

Regards Ravi

user642378
  • 167
  • 6
  • 12
  • 2
    Rewrite your question and only include relevant parts. Explain this: _"But drag files to shortcut is not working."_ - what is not working? What do you expect to happen and what does happen? – CodeCaster Feb 08 '13 at 09:12
  • 1
    Are you getting the arguments from the main of your program? When you drag and drop on a shourtcut it usually gets the path of the file as arguments in to the main I am trying it now. if it works I will post – Ali Akdurak Feb 08 '13 at 09:12
  • I am passing arguements and the application launches when drag files to the exe. My questions is after installing the msi the shortcut will be created in desktop and when drag files to this shortcut no action is performed. – user642378 Feb 08 '13 at 09:17
  • @user642378 there should not be any behavior difference in the shortcut's working. Is it directly linking to your exe? try creating a shortcut and it should work. If it works compare two shourtcuts and see what is different. – Ali Akdurak Feb 08 '13 at 09:21

1 Answers1

0

Here is a sample code which I have tried when you drop a file on a shourtcut or an exe. Windows automaticly sends the path of the as an arguments to the main of the program. Simple as that.

Try droping something on this little programs and you will see the path of the file dropped in the console.

class Program
{
    static void Main(string[] args)
    {
        for (int i = 0; i < args.Length; i++)
        {
            Console.WriteLine("ARGS>>" + args[i]);
        }

        Console.ReadLine();

    }
}

And If you are new to programing and don't have a main for your program where you directly start a form. You can use Environment.GetCommandLineArgs(); it stores the arguments send to the program my friend. Which in this situation it will have path to the whatever dropped on the shortcut.

Ali Akdurak
  • 3,841
  • 1
  • 18
  • 16
  • Yes, in my i have done and its works fime when files drag into .exe.. But its not working when files drag into shortcut which is created in desktop after installing ithe msi. – user642378 Feb 08 '13 at 09:19
  • How does your setup creates the shortcut? Does that shortcut works as usual but does not support dropping of files on it. Then I can only assume there is something wrong at the creation of shortcut with msi. Check what it is like. – Ali Akdurak Feb 08 '13 at 09:28
  • I rightclick on primaryoutput projectname (active) and selected create shortcut. – user642378 Feb 08 '13 at 09:41
  • @user642378 Did you tried my code in a new empty console under same conditions(with setup/handcreating the sourtcut)? Does it work and show you the path in a console window? It is very strange – Ali Akdurak Feb 08 '13 at 09:51