错误上传文件到SP的时候 - 找不到文件:C:\ WINDOWS \ SYSTEM32 \ INETSRV \

问题描述:

我用下面的代码上传文件到SharePoint文档库:错误上传文件到SP的时候 - 找不到文件:C: WINDOWS SYSTEM32 INETSRV

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'. 

我身边有GOOGLE了,而且好像我可能需要使用PostedFile.InputStream代替PostedFile.Name。

但如果设置fileToUpload等于oFile.PostedFile.InputStream,那么我不能够再使用这段代码:

using (FileStream fs = new FileStream(fileToUpload, FileMode.Open)) 

我想还是用这个代码,因为我需要访问FS .name稍后在我的代码中。

任何想法如何解决这个问题?

+0

http://*.com/questions/11877829/file-not-found-exception-once-deployed-to-server – 2014-10-28 16:27:54

+0

有看到这个问题......没有一个有用的答案。 – JAck28 2014-10-28 16:33:43