2014-10-28 106 views
0

我用下面的代碼上傳文件到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://stackoverflow.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

回答

相關問題