Suppose you have a application MyWebApps and it is published in IIS. This application has a webpage which uses the files from a remote server to which you will get access by using separate credentials given to you.
Now you are able to open the remote server folders using Windows Explorer or Runcommand.
But you are unable to retrieve the same files while running the application.Why?
The reason is your IIS account has different user credentials say IUSR_[MACHINE_NAME].But you remote server has different username and password.So you have to give the same credentials for IIS account which you are actually using to access the client server using some software like TFS.
So change the IIS account username and password and I am sure you are able to find the shared files.Hurrah :)
public void DeleteOldFiles()
DirectoryInfo di = new DirectoryInfo(MapPath("Temp//"));
FileInfo rgFiles = di.GetFiles("*.xml");
foreach (FileInfo fi in rgFiles)
string filename = fi.Name;
int index = filename.IndexOf("@");
string date = filename.Substring(0, index);
date = date.Replace("_", "/");
date = date.Replace("-", ":");
date = date.Replace("$", " ");
string strFromDate = date;
string strToDate = DateTime.Now.ToString();
if (DateTime.TryParse(strFromDate, out fromdate) && DateTime.TryParse(strToDate, out todate))
TimeSpan TS = todate - fromdate;
int daysDiff = TS.Days;
if (daysDiff > 7)
Here all files are stored with datetime attached to them before the filename in Temp folder.
We are trying to remove the datetime part from the respective filename so that we can delete the file if it is older than 1 week.