如何保存在C#中的物理位置的spfile [英] how to save spfile in physical location in c#
本文介绍了如何保存在C#中的物理位置的spfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要保存在物理位置spfile中。为前:c盘
i need to save the spfile in physical location. for ex: c drive.
我使用下面的代码得到文件:
i get the file using the code below:
using (SPSite 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.
推荐答案
使用 SPFile.OpenBinaryStream()
来打开文件:
SPFile file = ...;
using (Stream stream = file.OpenBinaryStream())
{
using (FileStream fs = File.OpenWrite("file path"))
{
// write file to the file stream here
}
}
这篇关于如何保存在C#中的物理位置的spfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文