I can't get this ftp upload file function I got from msdn to work:
I get an error on this line:Code:private static void uploadFile(string FTPAddress, string filePath, string username, string password) { //Create FTP request FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath)); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(username, password); request.UsePassive = true; request.UseBinary = false; request.KeepAlive = false; //Load the file FileStream stream = File.OpenRead(filePath); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Close(); //Upload file Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); }
Stream reqStream = request.GetRequestStream();
saying: Error 550, Permissions denied
Which is not a C# error, but an FTP error from my ftp server stating that I need more permissions, but I already have full and if I log onto the ftp in another client I can upload files to any directory.
Therefore something must be wrong with the code, anyone that got a clue?




Reply With Quote