File.open文件创建错误

时间:2012-09-25 09:57:18

标签: asp.net vb.net

我正在尝试使用以下方法创建文件:

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

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

尝试以下

  • 确保tempemail存在
  • 确保应用程序池用户具有该文件夹的写入权限。