Cannot write file in classic asp

Ok, some time has passed since I was working with classic asp, so I'm a little rusty. Here is my question.

I am trying to write a file to a file system using FSO. The code below is very simple. However, the file does not appear and errors do not appear. I know that it runs the code, because I can add response.writes before and after this fragment, and both of them appear in the output. However, the file is not created, the error does not occur. I even changed it to be a dummy way to cause an error. No dice. I added that everyone read and write permissions in the directory. Nevertheless.

Ideas?

Here is 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
+3
source share
2 answers

:

<%

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

%>

.

: http://www.freevbcode.com/ShowCode.Asp?ID=89

+4

, , , :

On Error Resume Next

, . , .

( , , .)

, , , , , , :

Set objTextStream = objFSO.OpenTextFile("d:\test.txt", True)

, -. 1 :

Set objTextStream = objFSO.OpenTextFile("d:\test.txt", 1, True)

CreateTextFile:

Set objTextStream = objFSO.CreateTextFile("d:\test.txt", True)
+6

Source: https://habr.com/ru/post/1708897/


All Articles