我正在尝试访问和修改我之前上传到 webdav URL 的文件的属性“creationdate”和“lastmodified”。根据https://www.rfc-editor.org/rfc/rfc4918,我收到响应“HTTP/1.1 424 Failed Dependency”,我将其解释为“由于先前的请求失败导致请求失败” 。
我不知道以前的请求在这里失败了,因为当我运行代码时,我没有得到任何错误。这是代码:
FileInfo^ myfI=gcnew FileInfo(myfilePath);
String^ mytime=myfI->LastWriteTimeUtc.ToFileTimeUtc().ToString();
String^ strBody = "<?xml version=\"1.0\"?>"
+ "<d:propertyupdate xmlns:d=\"DAV:\">"
+ "<d:set>"
+ "<d:prop>"
+ "<creationdate>" + myfI->CreationTimeUtc.ToFileTimeUtc().ToString() + "</creationdate>"
+ "</d:prop>"
+ "<d:prop>"
+ "<lastmodified>" + mytime + "</lastmodified>"
+ "</d:prop>"
+ "</d:set>"
+ "</d:propertyupdate>";
array<Byte>^ mybytes= Encoding::UTF8->GetBytes(strBody);
String^ responseresult="";
String^ filename= myfI->Name;
System::Net::HttpWebRequest^ httpPutRequest = (System::Net::HttpWebRequest^)System::Net::WebRequest::Create(this->myURL + destinationpath+ "/" + filename);
httpPutRequest->Credentials = gcnew NetworkCredential(this->myUserName, this->myPassword);
httpPutRequest->PreAuthenticate = true;
httpPutRequest->Method = L"PROPPATCH";
httpPutRequest->ContentType = "text/xml";
httpPutRequest->ContentLength = mybytes->Length;
Stream^ requestStream = httpPutRequest->GetRequestStream();
requestStream->Write(mybytes,0,mybytes->Length);
requestStream->Close();
HttpWebResponse^ httpPutResponse = (HttpWebResponse^)httpPutRequest->GetResponse();
responseresult=httpPutResponse->StatusDescription;
HttpStatusCode mycode=httpPutResponse->StatusCode;
Stream^ myresponse=httpPutResponse->GetResponseStream();
StreamReader^ myr=gcnew StreamReader(myresponse);
String^ res=myr->ReadToEnd();
我也只尝试了一个属性并且得到了相同的响应。
请问有什么建议吗?