How to check if a file exists when it was no file extension? C# -


this question has answer here:

the file test has no extension , need either move or rename file extension

if(file.exists(@"c:\\users" + environment.username + "\\desktop\\test")) {                                                                 /\                                                file has no file extension } 

i created file named test no extension in folder m:\incoming.

running following code works in both cases:

if (file.exists(@"m:\incoming\test"))     console.writeline("exists");  if (file.exists(@"m:\\incoming\\test"))     console.writeline("exists"); 

when using @ not need specify 2 slashes, although makes no difference anyway in example.

output:

exists

exists

your problem in way in concatenating strings.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -