mercredi 25 février 2015

Open custom file, args is always empty

I have C# WinForm .NET 4.5 application. I set Project -> Properties -> Publish -> Options -> File Associations. This part seems to work because it sets icon that I selected and if I double click file with custom extension (in this case *.psi) it opens my application. But I am having hard time getting file name that was double clicked. Somehow my static void Main(string[] args) args are always empty.


Can anyone help me with what I am missing to open custom file with my application.



static void Main(string[] args)
{
if(args.Length > 0)
{
MessageBox.Show(args[0]);
}else {
MessageBox.Show("args is empty!");
}

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DevExpress.Skins.SkinManager.EnableFormSkins();

UserLookAndFeel.Default.SetSkinStyle(Properties.Settings.Default.ActiveSkinName);


Application.Run(new MainForm(args));
}

Aucun commentaire:

Enregistrer un commentaire