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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -