I used the following code to implement the right clicked file that opened by my application. My aim is to get that file's path into my program.
I use:
public static string path = "";
static void Main(string[] args)
{
if (args.Length > 0)
{
path = args[0];
}
}
Then I use the variable path
, which is the file that opened by the application through the context menu.
Problem:
When the file name doesn't contain any spaces, the file path is imported without any problems. But when the file name contains any spaces, the file name shown without its extension besides it removes letters after the first space in the file name.
Example:
fileName.pdf
→fileName.pdf
fileName blah blah.pdf
→filename
The second example shown that the file that contains spaces didn't imported as it should.
So, if there is any idea of how to parse the files that contains spaces without any problems with its name.