读书人

ASP创建文件失败 代码如下解决方案

发布时间: 2012-02-24 16:30:39 作者: rapoo

ASP创建文件失败 代码如下
提示错误:错误类型:
Microsoft VBScript 运行时错误 (0x800A0005)
无效的过程调用或参数
/formhandler.asp, 第 13 行

经过检查是formhandler.asp
path = "c: emp est.txt " ForReading = 1, ForWriting = 2, ForAppending = 3
经过修改path = "c:\emp\est.txt "
还是错误????
不知道如何改

顺便问如何在asp代码生成html 或vml文件 (好象不能象写text文件 直接生成)


< html> < body>
< form action= "formhandler.asp " method= "post "> < input type= "text " size= "10 " name= "username "> < input type= "text " size= "10 " name= "homepage "> < input type= "text " size= "10 " name= "Email "> < /form> < /body> < /html>
   再看看formhandler.asp中处理表单的代码:
< % ' Get form info strName = Request.Form( "username ") strHomePage = Request.Form( "homepage ") strEmail = Request.Form( "Email ")
' create the fso object Set fso = Server.CreateObject( "Scripting.FileSystemObject ")
   迄今为止,还没有新鲜的东西,无非是获取表单域的值并且赋值到变量。下面出现了有趣的部分 - 写文件:
path = "c: emp est.txt " ForReading = 1, ForWriting = 2, ForAppending = 3
' open the file set file = fso.opentextfile(path, ForAppending, TRUE)
' write the info to the file file.write(strName) & vbcrlf file.write(strHomePage) & vbcrlf file.write(strEmail) & vbcrlf
' close and clean up file.close set file = nothing set fso = nothing

[解决办法]
HTML也就是TXT文件,扩展名不同而已,可以生成
看我的

'生成HTML页面
Set fso = CreateObject( "Scripting.FileSystemObject ")
filepath= "../tjnews/ "&listpath& "/ "&hour(now)&minute(now)&second(now)& ".html "

Set tf = fso.CreateTextFile(server.MapPath(filepath), True)
tf.WriteLine( " <html> <head> ")
tf.WriteLine(content)
.........................
tf.Close
set tf=nothing
[解决办法]
tf.WriteLine " <a href=test.html> SDFSDFSDFSDF </a> "
[解决办法]
如果是变量,

tf.WriteLine " <a href= "&var& "> SDFSDFSDFSDF </a> "
[解决办法]
tf.WriteLine " <a href= " "test.html " "> SDFSDFSDFSDF </a> "

读书人网 >ASP

热点推荐