Ok, so I am testing uploading files to an FTP server by attempting to upload a text file with the contents of "HELLO WORLD". I am given a return of" "upload file completed System.Net.WebClient error -> cancelled ->False". The file seems to appear on the server but when I open it, the contents read:
--------------8d30e4d69803578
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: application/octet-stream
HELLO WORLD
--------------8d30e4d69803578
the code I am using is:
string ftpUserName = "ftpUserName";
string ftpPassword = "ftpPassword";
string ftpURL = "ftp://ftpServer.com/text.txt";
string path = "pathToFile/test.txt"
public static void Test()
{
System.Uri uri = new System.Uri(ftpURL);
FileInfo file = new FileInfo(path);
if (!file.Exists)
{
return;
}
using(WebClient wc = new WebClient())
{
wc.Credentials = new NetworkCredential(ftpUserName,ftpPassword);
wc.UploadFileCompleted += UploadFileCompleted;
wc.UploadFileAsync(uri,"STOR",path);
}
}
Any help would be appreciated
edit
I also just tried with a zip file and it is corrupt. Both the .txt and .zip are also far smaller once they reach the server, so I am assuming the upload has failed because of that error
edit 2
solved it using .net2.0's version of the FtpWebRequest