文档集导出问题 [英] DocumentSet Export Issue

查看:61
本文介绍了文档集导出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您好,

Hi,

我尝试将文档集从一个网站集复制到另一个网站集。

I trying to copy a documentset from one site collection to another one.

为此我正在尝试使用DocumentSet的Export()方法,但该方法会引发异常。 (无法在文档集中创建文件夹)

For that i'm trying to use the Export() method of a DocumentSet but the method rise an exception. (Cannot create a folder in a Document Set)

https://imgur.com/ob24TSj

我还没有找到任何解决方案。

I haven't found any solution.

有什么想法吗?

推荐答案

我无法重现此问题。你能提供你的代码吗?

我尝试了以下代码。 Export()有效。

using System;

using Microsoft.SharePoint;

using Microsoft.Office.DocumentManagement.DocumentSets;

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            SPSite site = null;

            SPWeb web = null;

            try

            {

              

                using (site = new SPSite("http://sp/sites/sp10"))

                {

                    using (web = site.OpenWeb())

                    {

                        SPList list = web.Lists["doc1"];

                        foreach (SPListItem item in list.Items)

                        {

                            if (item.Folder != null)

                            {

                                Console.WriteLine("item.folder:"+item.Folder);

                                DocumentSet newDocset = DocumentSet.GetDocumentSet(item.Folder);

                                if (newDocset != null)

                                {

                                    byte[] compressedFile = newDocset.Export();

                                    string docsetname = newDocset.Item.Name;

                                    Console.WriteLine("Export:" + docsetname);

                                   

                                }

                            }

                        }

                        web.Close();

                    }

                    Console.ReadLine();

                }

            }

            catch (InvalidOperationException ioEx)

            {

                string msgErro = string.Format("HResult: {0} - Source: {1} - Message: {2}", ioEx.HResult, ioEx.Source, ioEx.Message);

                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine("Erro: " + msgErro);

                Console.ResetColor();

                Console.ReadLine();

            }

            catch (SPException spEx)

            {

                string msgErro = string.Format("HResult: {0} - ErrorCode: {1} - Source: {2} - Message: {3}", spEx.HResult, spEx.ErrorCode, spEx.Source, spEx.Message);

                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine("Erro: " + msgErro);

                Console.ReadLine();

                Console.ResetColor();

            }

            catch (Exception ex)

            {

                string msgErro = string.Empty;

                Exception curEx = ex;

                do

                {

                    if (!string.IsNullOrEmpty(curEx.Message) && !curEx.Message.Contains("One or more errors occurred"))

                    {

                        if (!string.IsNullOrEmpty(msgErro)) msgErro += "; ";

                        msgErro += curEx.GetType().ToString() + " - " + curEx.Message;

                    }

                    curEx = curEx.InnerException;

                } while (curEx != null);

                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine("Erro: " + msgErro);

                Console.ReadLine();

                Console.ResetColor();

            }

            if (web != null) try { web.Close(); }

                catch (Exception) { }

            if (site != null) try { site.Close(); }

                catch (Exception) { }

        }

    }

}





以编程方式删除文档集的演示供您参考:

https://social.msdn.microsoft.com/Forums/en-US/ 1e8b1110-a719-4825-a300-cc1946f4d96a / document-sets-move-programatically?forum = sharepointdevelopmentprevious

最好的问候,

Linda Zhang


这篇关于文档集导出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆