Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Console.WriteLine("Uploading");
  2. FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://domain.tld/file.json");
  3. request.Method = WebRequestMethods.Ftp.UploadFile;
  4. request.Credentials = new NetworkCredential("username", "password");
  5. StreamReader sourceStream = new StreamReader("file.json");
  6. byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
  7. sourceStream.Close();
  8. request.ContentLength = fileContents.Length;
  9. Stream requestStream = request.GetRequestStream(); //It gets stuck on this line
  10. requestStream.Write(fileContents, 0, fileContents.Length);
  11. requestStream.Close();
  12. Console.WriteLine("Uploaded");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement