c# - File.Exists yields false, but the file exists -


i have strange issue using file.exists in c#, reproducable on several pc's. see error in .net 4 library.

i use 7zip , automate c# program, call createprocess , zip , unzip files it. that, need find out if , 7zip installed, because don't want depend on path variables.

so part of code:

if (file.exists(environment.getfolderpath(environment.specialfolder.programfiles) + "\\7-zip\\7z.exe"))     clsglobal.gstr_zip_prog_mit_pfad = "\"" + environment.getfolderpath(environment.specialfolder.programfiles) + "\\7-zip\\7z.exe\"";  else if (file.exists("\"c:\\program files (x86)\\7-zip\\7z.exe\""))     clsglobal.gstr_zip_prog_mit_pfad = "\"c:\\program files (x86)\\7-zip\\7z.exe\""; 

all exist-checks give me "false" back. programfiles-specialfolder points right (x86)-folder, sure. , sure, 7zip installed in c:\program files (x86)\7-zip\7z.exe, , when calling createprocess, works fine. can reason why exists() - checks fail ? known bug ?

i dukeling correct in comment

"\"c:\\program files (x86)\\7-zip\\7z.exe\"" 

is looking path starting double quotes before c:\ must not named said use "@" before string becomes:

@"c:\program files (x86)\7-zip\7z.exe\"

this makes code readable , prevents confusion quotes seems happening here.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -