I am trying to write a file to a specific location on a shared folder. This shared folder is accessible to only few people. But in the code, I want to take either windows credentials or give certain username and password. But, when I try it always shows me Access denied. I want to pass certain credentials or windows network login credential. How can I achieve that ?
string destFilename = @"\\test.net\excel\docs\test.xls";
System.Net.WebClient client = new System.Net.WebClient();
WebDownload w = new WebDownload(3600000);
UTF8Encoding objUTF8 = new UTF8Encoding();
byte[] data = w.DownloadData();
WebRequest request = WebRequest.Create(destFilename);
File.WriteAllBytes(destFilename, data); //ACCESS DENIED
EDIT
It is a console application