Stack Overflow Asked on December 5, 2021
I thought it was due to some permission issue, but that does not seem to be the case. The file has "Read & Execute, Read" permissions for "Users", and "Full control" for "Administrators" and "SYSTEM". Can there be other reasons why File.Exists()
returns false
?
PS: I did not think the code was important, so I did not type the code, but if that is the rule, here is the text version of the code.
static void Main(string[] args)
{
var app = @"C:Program Files(x86)VideoLANVLCvlc.exe";
var psi = new ProcessStartInfo();
psi.FileName = Path.GetFileName(app);
psi.WorkingDirectory = Path.GetDirectoryName(app);
Process.Start(psi);
}
Anyway, there seems to be a weird behaviour of pasting path in Visual Studio. If I use "Copy as path" in File Explorer and paste it into an empty string, VS removes the space between Files
and (x86)
.
On your file-system, there's a space between Files
and (x86)
. You don't have that in the string you're using to get at the file, so it should be changed to:
var app = @"C:Program Files (x86)VideoLANVLCvlc.exe";
// ^
// need this
In terms of your statement that:
Anyway, there seems to be a weird behaviour of pasting path in Visual Studio. If I use "Copy as path" in File Explorer and paste it into an empty string, VS removes the space between
Files
and(x86)
.
That's almost certainly down to auto-formatting, which is done on paste among other things (though you can disable it, or use CTRL+Z to back up, since it appears to paste and then format).
Since you paste a "quoted thing"
inside quotes to end up with ""quoted thing""
, the quoted thing
bit is now outside quotes and therefore subject to auto-formatting.
Had you copied the file name without the quotes, or copied it with the quotes but pasted to a non-quoted area, I suspect it would have been put in unmodified (as a quoted string).
Answered by paxdiablo on December 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP