Monday, December 17, 2007

How to delete the text file in the web server

How to delete the text file in the web server

S T E P - 1

- We need to use the FileSystemObject object:

<%

Const ForReading = 1, ForAppending = 8 'Set the iomode

Dim fSys

Set fSys = CreateObject("Scripting.FileSystemObject")

%>

S T E P - 2

- We can use the server.mappath(".") to get the webserver's current folder.

- After that, use the Deletefile method to delete the file that we selected.

<%

fSys.DeleteFile(server.mappath(".") & "\myFile.txt")

Response.write("Process delete file")

Set fSys = Nothing

%>

No comments: