Windows 10 cannot access the specified device, path, or file when using full path to executable, running as Administrator

前端 未结 2 873
一生所求
一生所求 2021-02-04 16:41

Note : I\'ve replace the directory with a and the exe with b.exe and I\'ve repeat every test I have made to make sure it\'s not a typi

相关标签:
2条回答
  • 2021-02-04 17:19

    I found it !!

    It's some extra non-printable bytes added in file path when Copying / Pasting from some labels in Windows 10 explorer.

    Consider this piece of code :

    Console.WriteLine(new DirectoryInfo(@"c:\a\"));
    Console.WriteLine(new DirectoryInfo(@"‪c:\a\"));  
    

    These line looks the same and should not raise any exception (even if directory c:\a doesn't exist) but actually if you copy/paste the code above in an application, the second line will raise NotSupportedException with words : "The given path's format is not supported".

    I've ended up checking .NET source code and I found method StringExpressionSet.Canonicalize which raised NotSupportedException :

    ...
     if (path.IndexOf( ':', 2 ) != -1)
          throw new NotSupportedException( Environment.GetResourceString( "Argument_PathFormatNotSupported" ) );
    ...
    

    And actually :

    Console.WriteLine(@"c:\a\".IndexOf( ':', 2 )); //  results -1
    Console.WriteLine(@"‪c:\a\".IndexOf( ':', 2 )); //  result 2
    // Copy/Paste to test
    

    Where did I caught it ?

    In order to not making any typing mistake, I'm used to copy directory path from Right Click to a file -> Properties -> Security

    You are warned now !

    0 讨论(0)
  • 2021-02-04 17:26
    ...SystŠme
    ...authentifi‚s
    

    Obfuscating the directory and file name makes it very hard to help you. But there's one obvious rock to look under, getting the accented characters mangled so badly like this should never happen. The machine speaks French but the encoding that appears to be used is 1250, only used in Eastern Europe. A very bizarre mismatch, especially so for a console mode app.

    If the real a directory likewise contains characters with diacritics then whatever root cause behind the mangled icalcs.exe program output could affect the file system name encoding as well. Rough conclusion is that this machine is pretty sick and needs help from the geek squad to get better.

    0 讨论(0)
提交回复
热议问题