public static void UploadFile(byte[] fileData) {
var copy = new Copy {
Url = "http://servername/sitename/_vti_bin/copy.asmx",
UseDefaultCredentials = true
};
string destinationUrl = "http://servername/sitename/doclibrary/filename";
string[] destinationUrls = {destinationUrl};
var info1 = new FieldInformation
{
DisplayName = "Title",
InternalName = "Title",
Type = FieldType.Text,
Value = "New Title"
};
FieldInformation[] info = {info1};
var copyResult = new CopyResult();
CopyResult[] copyResults = {copyResult};
copy.CopyIntoItems(
destinationUrl, destinationUrls, info, fileData, out copyResults);
}
注:更改的CopyIntoItems
的文件名,Path.GetFileName(destinationUrl)
的第一個參數,使得取消鏈接消息消失。
當文件已經存在時,是否發現有錯誤的問題?我開始使用這種技術,但發現我經常收到錯誤「無法在請求的目的地創建項目,請確認文件夾存在並且您有權編輯它」。還有其他人有這個問題嗎? – misteraidan 2009-07-01 00:05:58