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 :
- I'm running windows as Administrator
- The user has access to the file (security attribute enable for everyone in the computer).
c:\b.exe
works !!- I'm not looking for a solution like change your application working directory and run Process.Start("b.exe").
Thank you all,
EDIT :
- The specified path is not WRONG and the file is not missing.
- Every user of the computer as Total control level acceess over the folder and the file (
a
directory andb.exe
) - Works when I put the exe on the root directory : "c:\b.exe"
- Same behaviour with .bat file with only "echo Hello inside"
Console.WriteLine(String.Join("\r\n", Directory.GetDirectories(@"c:\")))
display the directoryc:\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()