I have the following method:
public static DataSet BringProducts()
{
DataSet dataSet = new DataSet();
var dir = @"ProductsCookieData.xml";
if (File.Exists(dir)) //without File.Exists, same problem.
{
dataSet.ReadXml(dir);
}
return dataSet;
}
The file exists but the method does not see it ever. The file is in C:\, I tried in other locations and the same happens. Also tried without using static.
If I don’t use the File.Exists(), FileNotFoundException is throwing.
With the way you declared the file
Your file has to be in the same directory as your code/current webpage and not in C:. You can give permission to C:\ and change your code to
Sometimes, the file can be copied to your application folder, root or special folder and accessed with Server.MapPath