i want to upload a file to server and here is my code which do not work
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://mysite.com/myfolder");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("aaa", "aaa");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("c://a.txt");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
i can access ftp through filezilla with these credentials.nothing is uploading in this case. Now when i want to upload to another folder inside like ftp://mysite.com/myfolder/anotherfolder if give me error that file or folder not availble etc etc any help?