|
-
May 7th, 2011, 02:27 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] FTP Upload Error
I can't get this ftp upload file function I got from msdn to work:
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();
}
I get an error on this line:
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?
-
May 8th, 2011, 03:48 AM
#2
Thread Starter
Hyperactive Member
-
May 9th, 2011, 02:14 PM
#3
Re: [RESOLVED] FTP Upload Error
Delete it. They just clutter threads anyway.
-
May 9th, 2011, 03:34 PM
#4
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|