daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jan 28th, 2016 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top