2012-09-25 68 views
0

我試圖用創建一個文件:File.open文件創建錯誤

Dim stmFile As Stream = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Write) 

這應該創建一個文件中指定的文件目前不存在但相反,它拋出一個服務器錯誤:

Could not find a part of the path 'c:\tempemail\681968_File.doc'. 

Description: An unhandled exception occurred during the execution of the current web 
request. Please review the stack trace for more information about the error and where 
it originated in the code. 

Exception Details: System.IO.DirectoryNotFoundException: 
Could not find a part of the path 'c:\tempemail\681968_File.doc'. 

有什麼建議嗎?

+0

你傳遞給文件名的值是「c:\ tempemail \ 681968_File.doc」還是「c:\\ tempemail \ 681968_File.doc」? –

+0

tempemail目錄是否已經存在? – bUKaneer

+0

Filename =「c:\ tempemail \ 681974_File.doc」 –

回答

1

請嘗試以下

  • 確保tempemail存在
  • 確保應用程序池用戶具有寫權限的文件夾。