How to check if a file exists when it was no file extension? C# -
this question has answer here:
- how move file has no file extension? c# 3 answers
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
Post a Comment