programming-examples/asp/FilesMaths/MkFile Statement.asp

27 lines
810 B
Plaintext
Raw Permalink Normal View History

2019-11-18 14:25:58 +01:00
<%
' Make an asp file named File in the directory New Folder
MkFile Server.MapPath("/New Folder/File.asp")
%>
source code:
<%
Private Sub MkFile(ByVal pathname)
Dim objFSO, boolErr, strErrDesc
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(pathname) Then
Err.Raise 5106, "MkFile Statement", "File [" & pathname & "] " & _
"Already Exists. Use the Kill statement to delete files."
Else
On Error Resume Next
objFSO.CreateTextFile pathname, 2, True
If Err Then
boolErr = True
strErrDesc = Err.description
End If
On Error GoTo 0
If boolErr Then Err.Raise 5106, "MkFile Statement", strErrDesc
End If
Set objFSO = Nothing
End Sub
%>