My application is only for me and co-workers, so I don\'t care if it\'s Click-Once or copy-the-exe. I want to be able to click a file with given extension in windows explor
First of all you should add file assoc for ClickOnce-publish (Select Project->Properties->Publish-Options->File Associations)
Then add Reference to "System.Deployment"
Then you could extract path in App.cs in such a manner, depending on type of startup (ClickOnce or Local)
protected override void OnStartup(System.Windows.StartupEventArgs e)
{
var path = GetPath (e);
}
private static string GetPath(StartupEventArgs e)
{
if (!ApplicationDeployment.IsNetworkDeployed)
return e.Args.Length != 0 ? e.Args[0] : null;
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments == null)
return null;
var args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
return args == null || args.Length == 0 ? null : new Uri(args[0]).LocalPath;
}