不能写在传统的ASP文件 [英] Can't write file in classic asp
问题描述
好吧,它已经有一段时间,因为我已经与传统的ASP的工作,所以我有点生疏。这里是我的问题。
我试图写一个文件来使用FSO文件系统。下面的code是非常简单的。但是,文件没有出现,也没有错误出现。我知道它的运行了code,因为我这个片段之前和之后添加response.writes,他们都出现在输出中。但是,创建任何文件,不会引发错误。所以这是强制的错误伪造的路径我甚至改变了它。没有骰子。我说大家已经阅读并在目录权限写。还是一样。
想法?
下面是我的code:
暗淡objFSO
设置objFSO =的Server.CreateObject(Scripting.FileSystemObject的)打开文本文件
昏暗objTextStream
设置objTextStream = objFSO.OpenTextFile(D:\\ test.txt的,真)显示文本文件的内容
objTextStream.WriteLine你好关闭文件和清理
objTextStream.Close
设置objTextStream =什么
设置objFSO =没什么
试试这个:
<%如果追加= true则
iMode平台= 8
其他
iMode平台= 2
万一
设置OFS =的Server.CreateObject(Scripting.FileSystemObject的)
设置oTextFile = oFs.OpenTextFile(C:\\ wwwroot的\\ Test.txt的,iMode平台,真)
oTextFile.Write测试内容
oTextFile.Close
设置oTextFile =什么
设置OFS =什么%GT;
我试过这个地方,设置在我的目录的权限后,它的工作。
您可以从这里得到的原始来源:
HTTP://www.freevb$c$c.com /Show$c$c.Asp?ID=89
Ok, it's been a while since I've worked with classic asp so I'm a bit rusty. Here's my question.
I'm trying to write a file to the file system using FSO. The code below is very simple. However, the file is not appearing and no errors are appearing. I know it's running the code because I can add response.writes before and after this snippet and they both appear in the output. However, no file is created, no error is thrown. I've even changed it so it's a bogus path to force an error. No dice. I added everyone to have read and write on the directory permissions. Still the same.
Ideas?
Here's my code:
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("d:\test.txt", True)
'Display the contents of the text file
objTextStream.WriteLine "howdy"
'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
Try this:
<%
if Append = true then
iMode = 8
else
iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile("C:\wwwroot\Test.txt", iMode, True)
oTextFile.Write "Test Content"
oTextFile.Close
set oTextFile = nothing
set oFS = nothing
%>
I tried this locally, after setting the permissions on my directory and it worked.
You can get the original source from here: http://www.freevbcode.com/ShowCode.Asp?ID=89
这篇关于不能写在传统的ASP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!