【发布时间】:2014-10-29 01:00:53
【问题描述】:
我正在使用以下代码将文件上传到 SharePoint 文档库:
string fileToUpload = oFile.PostedFile.FileName;
using (SPSite oSite = new SPSite(spsite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList library = oWeb.Lists[documentLibraryName];
using (FileStream fs = new FileStream(fileToUpload, FileMode.Open))
{
//more logic here
这在我的开发环境中运行良好,但是当我将其移至 QA 时,尝试上传文件时出现以下错误:
System.IO.FileNotFoundException:
Could not find file 'c:\windows\system32\inetsrv\file_to_upload'.
我用谷歌搜索了一下,似乎我可能需要使用 PostedFile.InputStream 而不是 PostedFile.Name。
但是如果设置fileToUpload等于oFile.PostedFile.InputStream,那么我就不能再使用这段代码了:
using (FileStream fs = new FileStream(fileToUpload, FileMode.Open))
我想仍然使用此代码,因为稍后我需要在我的代码中访问 fs.name。
知道如何解决这个问题吗?
【问题讨论】:
-
看过那个问题...没有有用的答案。
标签: sharepoint-2010 filestream