I want to catch exceptions in a log file. I want to name my log file by date. If the file exists, it should append to it, if file does not exist, it should create one. I tried the following code but get error access to path is denied. I have shared the logs folder and given full control to every one. Please suggest what needs to be done.
I am getting the correct FileName as 11-11-2010.txt and Fullname (with path) as \\myserver\Projects\Result
Error: Access to the path '\\myserver\Projects\Resul
xt' is denied.
public void WriteLog(string TextStr)
string FilePath = ConfigurationManager.AppSettings["LogPath"].ToString();
//Set Filename By Date
string FileName = DateTime.Now.ToString("MM-dd-yyyy") + ".txt";
string FullName = FilePath + FileName;
//if file does not exist, create one
FileStream fileStream = new FileStream(@FullName, FileMode.Append);
SW = File.AppendText(FullName);