【问题标题】:Error when uploading file to SP - could not find file: c:\windows\system32\inetsrv\将文件上传到 SP 时出错 - 找不到文件:c:\windows\system32\inetsrv\
【发布时间】: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


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2021-05-21
  • 1970-01-01
  • 1970-01-01
  • 2011-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-06
相关资源
最近更新 更多