I am working with the tutorial here: http://www.devtoolshed.com/content/c-download-file-progress-bar and I am receiving an UnauthorizedAccessException on the following line of code
using (Stream streamLocal = new FileStream(sPathToWriteFilesTo,
FileMode.Create, FileAccess.Write, FileShare.None))
{
//...
}
Perhaps it is something with permissions of the file I am trying to read? It is just a simple text file requested using FTP (instead of HTTP as the tutorial shows).
string sFtpToReadFilesFrom = "ftp://<user>:<pass>@mysite.tk/updates/App_Data/output_log.txt";
string sPathToWriteFilesTo = Application.StartupPath + "\\App_Data";
Uri url = new Uri(sFtpToReadFilesFrom);
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(url);
request.Timeout = 10000;
request.ReadWriteTimeout = 10000;
request.Method = WebRequestMethods.Ftp.GetFileSize;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
If anyone sees any immediate red flags with the FtpWebRequest please do let me know. I am primarily concerned with the UnauthorizedAccessException and how to fix that.