WebDAV新建文件夾(MKCOL)
private void WebDAVNewFolder_Click(object sender, EventArgs e)
{
try
{
// Create the HttpWebRequest object.
HttpWebRequest objRequest = (HttpWebRequest)HttpWebRequest.Create(@"http://10.57.144.2/WebDAV/new");
// Add the network credentials to the request.
objRequest.Credentials = new NetworkCredential("F3226142", "drm.123");//用户名,密码
// Specify the method.
objRequest.Method = "MKCOL";
HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();
// Close the HttpWebResponse object.
objResponse.Close();
}
catch (Exception ex)
{
throw new Exception("Can't create the foder" + ex.ToString());
}
}
WebDAV上传代码(PUT)
System.Uri myURi = new System.Uri("http://10.57.144.2/WebDAV/hello.doc");
FileStream inStream = File.OpenRead("C://timeTest.doc");
WebRequest req = WebRequest.Create(myURi);
req.Method = "PUT";
req.Timeout = System.Threading.Timeout.Infinite;

最低0.47元/天 解锁文章
5693

被折叠的 条评论
为什么被折叠?



