开发者

how to save spfile in physical location in c#

i need to save the spfile in physical location. for ex: c drive.

i get the file using the code below:

using (SPSi开发者_运维技巧te site = new SPSite(item.Web.Site.ID))
 {
  using (SPWeb web = site.OpenWeb(item.Web.ServerRelativeUrl))
   {
      SPFile file = web.GetFile(item.File.UniqueId);
   }
 }

now how to save file in physical location. please give some code.


Use SPFile.OpenBinaryStream() to "open" the file:

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

MSDN: SPFile.OpenBinaryStream

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜