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
精彩评论