c# - Playing with files that contain more than one consecutive space in their filenames -
in part of code, check if file exists , open it.
one employee encountered problem filenames containing more 1 space character.
i checked , it's true. here's snippet of code:
string filepath = path.combine(helper.milltestreportpath, filename); // ouverture du fichier if (file.exists(filepath)) { process.start(filepath); } else { messagebox.show("le fichier n'existe pas!", "fichier introuvable", messageboxbuttons.ok, messageboxicon.error); }
everything works find every file when file ("spam certs s o 94318099 p o 10610.msg" example) contains more 1 space, false file.exists , if directly try run process.start fails...
any idea how fix that?
thanks lot!
according msdn documentation, file.exists
returns:
true if caller has required permissions , path contains name of existing file; otherwise, false. method returns false if path null, invalid path, or zero-length string. if caller not have sufficient permissions read specified file, no exception thrown , method returns false regardless of existence of path.
if file exists, user trying access file not have necessary permissions.
Comments
Post a Comment