Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Command Line Argument Problem: Drag-drop file working, double-clicking not working

$
0
0

Hello!

In my WPF application made using Visual Studio 2015 Community, I'm handling the command line arguments as follows:

if (Environment.GetCommandLineArgs().Length > 1)
{
	string[] path = Environment.GetCommandLineArgs();
	MessageBox.Show("arg = " + path[1]);
}

When I'm testing command line arguments by passing them through project properties in Visual Studio, and also when I'm executing the application outside Visual Studio, manually passing the arguments, they're working properly and a MessageBox is popping up, as  expected.

Then I published this app using ClickOnce and associated an extension with it. Association is done properly since the file extension displays my file icon on it after installing the app. But when I double-click this file, my software opens as if there were no command line arguments. The software isn't going inside this IF block at all. I've tried manually dragging my file and dropping it over the .exe (in C:\Users\<username>\AppData\Local\Apps\2.0\...), then my file is opening properly and is recognized as the path being passed as command line argument, but still double-clicking the file is not working.

What could be the problem and how can I solve this?

Thanks!


- Prateek Jain


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>