自动升级组件中的错误:没法实例化Http请求流
在下载新版本时,需要请求列举目录文件,获得服务器该目录下所有文件,然后下载。
但发出XML请求的时候报错了。
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials;
string requestString = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
"<a:propfind xmlns:a=\"DAV:\">"+
"<a:prop>"+
"<a:displayname/>"+
"<a:iscollection/>"+
"<a:getlastmodified/>"+
"</a:prop>"+
"</a:propfind>";
Request.Method = "PROPFIND";
if (deep == true)
Request.Headers.Add("Depth: infinity");
else
Request.Headers.Add("Depth: 1");
Request.ContentType = "text/xml";
Request.ContentLength = requestString.Length;
Stream requestStream = null;
try
{
requestStream = Request.GetRequestStream();
//创建流的时候失败了。501错误。服务器不支持该函数!
//但我已经把该目录设为可“浏览目录“了. 不支持DAV??不明白了
}
catch (Exception er)
{
Debug.WriteLine("Z.J.Chen: Can't create a http request stream! "+er.Message);
requestStream.Close();
}