Advertisement
Guest User

Untitled

a guest
Jan 28th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. string szUsername = "c0relynx";
  2. string szPassword = "c0relynx";
  3. string szURL1 ="http://xx.xx.xx.xx/webdav/foobar1.txt";
  4. string szContent = String.Format(@"Date/Time: {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());
  5.  
  6. HttpWebRequest httpPutRequest = (HttpWebRequest)WebRequest.Create(szURL1);
  7.  
  8. httpPutRequest.Credentials = new NetworkCredential(szUsername, szPassword);
  9.  
  10. httpPutRequest.PreAuthenticate = true;
  11.  
  12. httpPutRequest.Method = @"PUT";
  13.  
  14. httpPutRequest.Headers.Add(@"Overwrite", @"T");
  15.  
  16. httpPutRequest.ContentLength = szContent.Length;
  17.  
  18. httpPutRequest.SendChunked = true;
  19.  
  20. httpPutRequest.KeepAlive = true;
  21.  
  22. Stream requestStream = httpPutRequest.GetRequestStream();
  23.  
  24. requestStream.Write(Encoding.UTF8.GetBytes((string)szContent), 0, szContent.Length);
  25.  
  26. requestStream.Close();
  27. HttpWebResponse httpPutResponse = (HttpWebResponse)httpPutRequest.GetResponse();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement