在Domin里新建文件夹代码

Domain:域名,地址名;

folderURL:Domain+文件夹名

如下就会在Domain一个文件夹

public bool CreateFolder(string folderURL)
        {
            try
            {
                WebRequest request = WebRequest.Create(folderURL);
                request.Credentials =  System.Net.NetworkCredential(ConfigurationManager.AppSettings["UserName"],
                ConfigurationManager.AppSettings["UserPassword"], ConfigurationManager.AppSettings["Domain"]);
                request.Method = "MKCOL";
                WebResponse response = request.GetResponse();
                response.Close();
                return true;
            }
            catch (WebException ex)
            {
                return false;
            }
        }

但以上只能一次建一个文件夹,像abc\bbc两级目录是不行的,只能先建abc 再在职abc下建bbc.

转载于:https://www.cnblogs.com/springyangwc/archive/2011/02/15/1955367.html

猜你喜欢

转载自blog.csdn.net/weixin_33805557/article/details/94228071