2011-03-08 2 views
3

나는 물리적 위치에 spfile을 저장해야합니다. ex : c 드라이브.C에서 실제 위치에 spfile를 저장하는 방법 #

나는 아래의 코드를 사용하여 파일을 얻을 :

using (SPSite site = new SPSite(item.Web.Site.ID)) 
{ 
    using (SPWeb web = site.OpenWeb(item.Web.ServerRelativeUrl)) 
    { 
     SPFile file = web.GetFile(item.File.UniqueId); 
    } 
} 

이제 물리적 위치에 파일을 저장하는 방법. 약간의 코드를주세요.

+0

내가는 SharePoint에 아니에요하지만 간단한 stramwriter가 작동하지 않습니다를? –

답변

6

사용 SPFile.OpenBinaryStream() 파일 "열기"하기 :

SPFile file = ...; 
using (Stream stream = file.OpenBinaryStream()) 
{ 
    using (FileStream fs = File.OpenWrite("file path")) 
    { 
    // write file to the file stream here 
    } 
} 

MSDN: SPFile.OpenBinaryStream

관련 문제