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 typing syntax.
I have a very simple piece code of which works perfectly from Windows XP to Windows 7.
var processPath = @"c:\a\b.exe" ; // this exe exists on my computer
Process.Start(processPath);
and also
Directory.Exists(@"c:\a\") returns false on Windows 10.
Since Windows 10 (I have not test yet 8 and 8.1) the first code will throws System.ComponentModel.Win32Exception
("Specified file not found") and second will return false. .
I've noticed also that it's the same behaviour when I run "c:\a\b.exe" with the windows run window (Windows Key + R).
Is there any workarounds to solve this issue? In preference, a solution which implies no recompilation.
NB :
c:\b.exe
works !!Thank you all,
EDIT :
a
directory and b.exe
)Console.WriteLine(String.Join("\r\n", Directory.GetDirectories(@"c:\")))
display the directory c:\a
UPDATE :
Results of icalcs c:\a\
:
c:\a\ Tout le monde:(OI)(CI)(F)
BUILTIN\Administrateurs:(I)(OI)(CI)(F)
AUTORITE NT\SystŠme:(I)(OI)(CI)(F)
BUILTIN\Utilisateurs:(I)(OI)(CI)(RX)
AUTORITE NT\Utilisateurs authentifi‚s:(I)(M)
AUTORITE NT\Utilisateurs authentifi‚s:(I)(OI)(CI)(IO)(M)
Results of icalcs c:\a\b.exe
:
c:\a\b.exe Tout le monde:(I)(F)
BUILTIN\Administrateurs:(I)(F)
AUTORITE NT\SystŠme:(I)(F)
BUILTIN\Utilisateurs:(I)(RX)
AUTORITE NT\Utilisateurs authentifi‚s:(I)(M)
"Tout le monde" means Everyone.
UPDATE :
On the last news, I'm able to do :
File.WriteAllBytes(@"c:\a\b.exe", somebinaries) ;
But I'm not able to do
FileInfo fileInfo = new FileInfo(@"c:\a\b.exe") ;
Throwing 'System.NotSupportedException'. StackTrace is as follows:
à System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
à System.IO.FileInfo.Init(String fileName, Boolean checkHost)
à System.IO.FileInfo..ctor(String fileName)
à ConsoleApplication1.Program.Main(String[] args) dans F:\MAPW10\Development\Sources\Tools\ConsoleApplication1\Program.cs:ligne 22
à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
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
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 !
...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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With