【问题标题】:Uploading files to a SharePoint document library with metadata将文件上传到带有元数据的 SharePoint 文档库
【发布时间】:2012-03-09 14:46:32
【问题描述】:

我正在使用以下代码将文件上传到 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*/ );   

【问题讨论】:

    标签: sharepoint metadata document


    【解决方案1】:

    我没有看到你在哪里添加元数据,我看到你填充了一个哈希表并且什么都不做

    【讨论】:

    • 我已经用完整的代码编辑了这个问题。你现在可以检查一下吗。
    猜你喜欢
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2016-04-29
    • 2010-10-01
    • 2013-12-12
    • 2010-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多