Reputation:
I have written a method to save xml file to my project.and I run that method automatically in specific time period(once a day(at 3.00 pm)), same file. but we have to include that file to the project manually.What I want is before xml file save, look if it is exists. if it is exists delete it and save the new one and include it. this is my code.
this is how I save ....
public void sendValue()
{
string wbserviceUrl = "https://someurl.ashx";
WebClient clientOne = new WebClient();
string result = clientOne.DownloadString(wbserviceUrl);
XmlDocument cruisexmlDocument = new XmlDocument();
cruisexmlDocument.LoadXml(result);
cruisexmlDocument.Save("D:/projects/booksmal/XmlFiles/Cruisedata/product.xml");
}
In here I want to check,
(Note: save the file is work fine)
Upvotes: 0
Views: 470
Reputation: 359
string path = Server.MapPath("~/XmlFiles/Cruisedata/product.xml");
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
Upvotes: 1