1
我使用下面的代碼上傳文件到SharePoint文檔庫,但它而不安裝元:我使用這個函數調用上傳文件到SharePoint文檔庫的元數據
private void UploadFileToSharePoint(string strInputFileName, string sDocLibraryName)
{
SPWeb site = SPContext.Current.Web;
SPList myList = site.Lists[sDocLibraryName];
string destFileUrl = myList.RootFolder.ServerRelativeUrl + @"/New.txt";
site.AllowUnsafeUpdates = true;
// FileStream fileStream = File.Open(strInputFileName, FileMode.Open);
byte[] strm = File.ReadAllBytes(strInputFileName);
// newFile.CheckIn("File added");
//SPListItem item = newFile.Item;
//item.File.CheckOut();
Hashtable ht = new Hashtable();
ht.Add("Status Indicator", "hello");
ht.Add("Status Description", Description.Text);
ht.Add("Status", "Delayed");
//item.Update();
//item.File.CheckIn("File with metadata");
myList.RootFolder.Files.Add(destFileUrl,strm,ht, true/*overwrite*/);
myList.Update();
}
:
UploadFileToSharePoint(@"C:\check.txt",
"Project Status" /* name of Dc Library*/);
我已經編輯全問題code..can請你檢查它現在。 – steve 2010-11-11 05:10:59