ฉันสร้างแอปที่ดาวน์โหลดไลบรารีเอกสารทั้งหมดในไซต์ SP แต่เมื่อถึงจุดหนึ่งมันทำให้ฉันมีข้อผิดพลาดนี้ (ฉันพยายามหาที่ google แต่ไม่พบสิ่งใดตอนนี้หากใครรู้เคล็ดลับในการแก้ปัญหานี้โปรดตอบกลับด้วยขอบคุณ สำหรับการดู)
System.IO.PathTooLongException: พา ธ ที่ระบุชื่อไฟล์หรือทั้งสองอย่างยาวเกินไป ชื่อไฟล์แบบเต็มต้องมีความยาวน้อยกว่า 260 อักขระและชื่อไดเร็กทอรีต้องน้อยกว่า 248 อักขระ ที่ System.IO.Path.NormalizePathFast (เส้นทางสตริงบูลีน fullCheck) ที่ System.IO.Path.GetFullPathInternal (เส้นทางสตริง) ที่ System.IO.FileStream.init (เส้นทางสตริงโหมด FileMode การเข้าถึง FileAccess สิทธิ์ Int32 บูลีน useRights , แชร์ FileShare, Int32 bufferSize, ตัวเลือก FileOptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) ที่ System.IO.FileStream..ctor (เส้นทางสตริง, โหมด FileMode, การเข้าถึง FileAccess, การแชร์ FileShare, Int32 bufferSize, ตัวเลือก FileOptions) ที่ System IO.File.Create (เส้นทางสตริง)
ถึงขีด จำกัด สำหรับสตริงรหัสจะได้รับด้านล่าง
#region Downloading Schemes
    private void btnDownload_Click(object sender, EventArgs e)
    {
        TreeNode currentNode = tvWebs.SelectedNode;
        SPObjectData objectData = (SPObjectData)currentNode.Tag;
        try
        {
            CreateLoggingFile();
            using (SPWeb TopLevelWeb = objectData.Web)
            {
                if(TopLevelWeb != null)
                    dwnEachWeb(TopLevelWeb, TopLevelWeb.Title, tbDirectory.Text);
            }
        }
        catch (Exception ex)
        {
            Trace.WriteLine(string.Format("Exception caught when tried to pass TopLevelWeb:{1}, Title = {2}, object data to (dwnEachWeb_method), Exception: {0}", ex.ToString(), objectData.Web, objectData.Title));
        }
        finally
        {
            CloseLoggingFile();
        }
    }
    private void dwnEachWeb(SPWeb TopLevelWeb, string FolderName, string CurrentDirectory)
    {
        if (TopLevelWeb != null)
        {
            if (TopLevelWeb.Webs != null)
            {
                CurrentDirectory = CurrentDirectory + "\\" + TopLevelWeb.Title;
                CreateFolder(CurrentDirectory);
                foreach (SPWeb ChildWeb in TopLevelWeb.Webs)
                {
                    dwnEachWeb(ChildWeb, ChildWeb.Title, CurrentDirectory);
                    ChildWeb.Dispose();
                }
                dwnEachList(TopLevelWeb, CurrentDirectory);
                //dwnEachList(TopLevelWeb, FolderName, CurrentDirectory);
            }
        }
    }
    private void dwnEachList(SPWeb oWeb, string CurrentDirectory)
    {
        foreach (SPList oList in oWeb.Lists)
        {
            if (oList is SPDocumentLibrary && !oList.Hidden)
            {
                dwnEachFile(oList.RootFolder, CurrentDirectory);
            }
        }
    }
    private void dwnEachFile(SPFolder oFolder, string CurrentDirectory)
    {
        if (oFolder.Files.Count != 0)
        {
            CurrentDirectory = CurrentDirectory + "\\" + oFolder.Name;
            CreateFolder(CurrentDirectory);
            foreach (SPFile ofile in oFolder.Files)
            {
                if (CreateDirectoryStructure(CurrentDirectory, ofile.Url))
                {
                    var filepath = System.IO.Path.Combine(CurrentDirectory, ofile.Url);
                    byte[] binFile = ofile.OpenBinary();
                    System.IO.FileStream fstream = System.IO.File.Create(filepath);
                    fstream.Write(binFile, 0, binFile.Length);
                    fstream.Close();
                }
            }
        }
    }
    //creating directory where files will be download        
    private bool CreateDirectoryStructure(string baseFolder, string filepath)
    {
        if (!Directory.Exists(baseFolder)) return false;
        var paths = filepath.Split('/');
        for (var i = 0; i < paths.Length - 1; i++)
        {
            baseFolder = System.IO.Path.Combine(baseFolder, paths[i]);
            Directory.CreateDirectory(baseFolder);
        }
        return true;
    }
    //creating folders
    private bool CreateFolder(string CurrentDirectory)
    {
        if (!Directory.Exists(CurrentDirectory))
        {
            Directory.CreateDirectory(CurrentDirectory);
        }
        return true;
    }
    //shorting string
    #endregion