Creating Text files on server

Moderator: Lixas

Post Reply
blue-sky
Posts: 33
Joined: Tue Jun 12, 2007 3:41 pm

Creating Text files on server

Post by blue-sky »

Creating Text files on server


In VBScript language there is no any function for Input/Output on hard disk. But you may use FileSystem Object to create and edit files on server. This is an indirect technics to create any file on server.

Here some examples for creating files on server :

Code: Select all

<%
set objFso = server.createobject("scripting.filesystemobject")
set objFile = objFso.CreateTextFile("sample.txt", true)
objFile.write "An example creating a file"
objFile.close
set objFile = nothing
objFso = nothing
%>


In this example, server create everytime a new file on same file. If you do not want to create any file with same name, change file mode to false


Code: Select all

<%
set objFso = server.createobject("scripting.filesystemobject")
set objFile = objFso.CreateTextFile("sample.txt", false)
objFile.write "An example creating a file"
objFile.close
set objFile = nothing
objFso = nothing
%>


Actually, you can not create file, because, you have already create same file.


Post Reply