2008-11-10 2 views

답변

7

사용자 정의 코드를 작성하여 작성할 수 있습니다. 동일한 서버에 있거나 웹 서비스를 사용하는 경우 SharePoint API를 사용할 수 있습니다.

문서 라이브러리의 URL을 알고 루트 폴더에 문서를 업로드한다고 가정 할 때 샘플 코드가 있습니다. 당신은 당신의 ASP.NET 프로젝트

 using (SPSite siteCollection = new SPSite(url)) 
     { 
      using (SPWeb spWeb = siteCollection.OpenWeb()) 
      { 
       SPList spList = spWeb.GetList(url); 

       string fileName = "XXXX"; 
       FileStream fileStream = null; 
       Byte[] fileContent = null; 

       try 
       { 
        string docPath = XXXX; //physical location of the file 
        fileStream = File.OpenRead(docPath + fileName); 
        fileContent = new byte[Convert.ToInt32(fileStream.Length)]; 
        fileStream.Read(fileContent, 0, Convert.ToInt32(fileStream.Length)); 

        spList.RootFolder.Files.Add(spList.RootFolder.Url + "/" + fileName, fileContent, true); 
        spList.Update(); 
       } 
       catch(Exception ex) 
       { 

       } 
       finally 
       { 
        if (fileStream != null) 
        { 
         fileStream.Close(); 
        } 
       } 
      } 
     } 
+0

전체 파일을 메모리로 읽는 대신 SPFolder.Add (url, Stream, overwrite)를 사용할 수도 있습니다 (성능 문제가 발생할 수 있음). 대용량 파일을 업로드하려는 경우) – Marek

2

보기 at this blog 게시물에 참조로 Microsoft.SharePoint.dll을 추가해야합니다. Bil Simser.

웹 서비스, 목록 및 문서를 업로드하기위한 모든 것을 사용하는 것에 대해서는 많은 논란이있는 것으로 보입니다. 그렇게 어려운 일은 아닙니다. Google에 약간의 시간을 보내고 (Google은 귀하의 친구입니다) 정규 HTTP PUT 명령을 통해 문서를 업로드 할 때 다양한 시도를 발견했습니다. ...

관련 문제