ASP FSO Use example tutorial

Source: Internet
Author: User

<% Function Er () ' Error handling
If Err.Number = 0 Then
Er = False
Else
Err.Clear
Er = True
End If
End Function
Sub Delfile (filename) ' This is a procedure for deleting files, and if no file name is specified, all files in that directory will be deleted
On Error Resume Next
Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
' Response.Write Path

Fs.deletefile Path,true
Set ts=nothing
End Sub
Sub Savetext (filename,data) ' This is a process for writing text files


Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
Set Ts=fs.createtextfile (path,true)
Ts.writeline (data)
Ts.close
Set ts=nothing
Set fs=nothing
End Sub
function testfile (FileName) ' This is a functions to detect whether a file exists
On Error Resume Next
Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
Pa=fs. GETFILE (PATH)
Set fs=nothing
If ER () then
Testfile=false
Else
Testfile=true
End If
End Function
function ReadText (FileName) ' This is a functions for reading text files

On Error Resume Next

Set Adf=server. CreateObject ("Ado" & "db". Str "&" Eam ")
If InStr (FileName, ":") <>0 Then
Path=filename
Else

Path=server. MapPath (FileName)
End If

With ADF
' Response.Write Path
. type=2
. Lineseparator=13
. Open
. LoadFromFile (PATH)
. charset= "GB2312"
. position=2
readtext=. ReadText
. Cancel ()
. Close ()
End With
Set adf=nothing
End Function

%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.