浏览文件夹并从GridView SharePoint.Client.dll下载文档

时间:2018-07-08 18:18:43

标签: c# asp.net sharepoint

我在使用SharePoint dll时遇到了一个大问题。

完成后需要做什么:我将使用SharePoint作为文件存储库,因此我将开发一个ASP页面,该页面将列出文件夹和共享文档,并可供下载。

>

疑问::我已经可以下载文件,但是只有url中指定的文件,而且我也不能在文件夹之间进行批处理(打开列出的文件夹)。

代码:在GridView中列出

    private void popular()
{
    using (ClientContext clientContext = new ClientContext("https://NomeDaEmpresa.sharepoint.com/sites/SubPasta))
    {
        DataTable dt = new DataTable();

        dt.Columns.Add("Nome", typeof(string));
        dt.Columns.Add("Tamanho", typeof(string));

        SecureString passWord = new SecureString();

        foreach (char c in "Password".ToCharArray()) passWord.AppendChar(c);

        clientContext.Credentials = new SharePointOnlineCredentials(Email, passWord);

        Web web = clientContext.Web;

        List oList = clientContext.Web.Lists.GetByTitle("Documentos");

        clientContext.Load(oList);
        clientContext.Load(oList.RootFolder);
        clientContext.Load(oList.RootFolder.Folders);
        clientContext.Load(oList.RootFolder.Files);
        clientContext.ExecuteQuery();

        FolderCollection fcol = oList.RootFolder.Folders;
        foreach (Folder f in fcol)
        {
            dt.Rows.Add(f.Name.ToString(), f.Size.ToString());
        }

        GridView1.DataSource = dt;
        GridView1.DataBind();

0 个答案:

没有答案
相关问题