Missing backslashes in filename using C#
- by CL4NCY
Hi,
I have a string literal as follows:
string filename = @"C:\myfolder\myfile.jpg";
When I use File.Exists(filename) it works most of the time but sometimes I get an error saying the following file doesn't exist:
C:myfoldermyfile.jpg
Something seems to strip the backslashes out of the filename. This code is sometimes accessed via an ajax request.
Does anyone know why/how this could be happening?
Edit:
Here is a more detailed version of the code.
public class Feeds {
public static string ftpDir = @"C:\website\Feeds\";
}
public class Feed {
public static void run(string name) {
if (!Directory.Exists(Feeds.ftpDir + name)){
Response.Write("Feed doesn't exist '" + Feeds.ftpDir + name + "'");
return;
}
//run feed...
}
}