请COPY下来自己测试...不说费话.......
<%
set Fso=server.createobject("Scripting.FileSystemObject")
Function FsoFile(f,min)
set Fp=Fso.CreateTextFile(server.mappath(f))
Fp.write(min) '写入内容
Fp.Close()
Response.Write("我在当前的目录创建了一个叫"&f&"的文件!")
End Function
Function FsoInstrInto(f)
set Fp=Fso.CreateTextFile(server.mappath(f))
For i = 0 To 10 '写入10行
Fp.WriteLine("·"&i&" 写入一行!一行一行的写。")
Next
Fp.Close()
Response.Write("写入文件信息!")
End Function
Function FsoReadFile(f)
set Fp=Fso.OpenTextFile(server.mappath(f))
While Not Fp.AtEndOfStream
Response.Write(Fp.ReadLine() + "<br>")
Wend
'While Not Fp.AtEndOfLine
'Response.Write(Fp.Read(1))
' Wend
Fp.Close()
End Function
Function SelectFile(f)
If Fso.FileExists(server.mappath(f)) Then
Response.Write("存在这个文件")
Else
Response.Write("不存在这个文件")
End If
End Function
Function CopyFile(f1,f2)
Fso.CopyFile server.mappath(f1),server.mappath(f2)
Response.Write("复制文件成功")
End Function
Function GetFiles(f1,f2)
set GF = Fso.GetFile(server.mappath(f1))
GF.Copy server.mappath(f2) '重令名
Response.Write("移动文件成功")
End Function
Function DeleteFile(f)
Fso.DeleteFile server.mappath(f)
Response.Write("删除文件成功")
End Function
Function Alert(str)
Response.Write(str)
End Function
Function Mswc()
Set Bc = Server.CreateObject("MSWC.BrowserType")
Response.Write "浏览器类型:" & Bc.Browser & "<br>"
Response.Write "浏览器版本:" & Bc.Version & "<br>"
Response.Write "支持Cookies否:" & Bc.Cookies & "<br>"
Response.Write "支持VBScript否:" & Bc.VBScript & "<br>"
Response.Write "支持JavaScript否:" & Bc.JavaScript & "<br>"
Response.Write "支持Java小程序否:" & Bc. Javaapplets
End Function
Function Drive(d)
set Dr= Fso.Getdrive(d)
Response.Write ( d &"驱动器总容量:"&Dr.Totalsize)
Response.Write ("<BR>"& d &"驱动器尚可提供容量:"&Dr.AvailableSpace)
set MyF = Fso.GetFolder("E:\pucb\website\FSO")
Response.Write("<BR>E:\pucb\website\FSO大小:")
Response.Write(MyF.Size)
End Function
Function FsoFolder()
If Not Fso.FolderExists("E:\pucb\website\FSO\123-A") Then '检查文件夹123A是否存在
Fso.CreateFolder ("E:\pucb\website\FSO\123" ) '创建文件夹
Fso.CopyFolder "E:\pucb\website\FSO\123","E:\pucb\website\FSO\123-A" '重命名文件夹为123-A
Fso.MoveFolder "E:\pucb\website\FSO\123","E:\\pucb\website\FSO\555" '移动文件夹
Response.Write("创建文件夹123,重命名文件夹为123-A")
Else
Response.write server.mappath("555")&"<BR>"
Response.write server.mappath("123-A")&"<BR>"
Fso.DeleteFolder "E:\pucb\website\FSO\555"
Fso.DeleteFolder "E:\pucb\website\FSO\123-A"
Response.Write("<BR>已经存在文件夹,但已删除")
End If
End Function
Function IsObjInstalled(strFsoString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strFsoString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
Function IsFso(strFsoString)
if IsObjInstalled(strFsoString) = False Then
Response.write("<h2><font color=red>不支持FSO</font></h2>")
Else
Response.write("<h2><font color=red>支持FSO</font></h2>")
End If
End Function
%>
<%
Function FileType(f)
set FT=Fso.GetFile(server.mappath(f))
%>
<table border=0><tr><td width=200>名称: <%=FT.Name %></td></tr>
<tr><td>路径: <%=FT.Path %></td></tr>
<tr><td>驱动器: <%=FT.Drive %></td></tr>
<tr><td>大小: <%=FT.size %></td></tr>
<tr><td>类型: <%=FT.type %></td></tr>
<tr><td>属性: <%=FT.Attributes %></td></tr>
<tr><td>创建日期:<%=FT.DateCreated %></td></tr>
</table><% End Function %>
<html><body><center>
====================================================================================================<br>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h3><a href="?action=create">创建文件</a></h3><h3><a href="?action=instrinto">写入文件</a></h3></td>
<td></td>
<td><h3><a href="?action=readfile">读起文件</a></h3><h3><a href="?action=Select">检测文件是否存在</a></h3></td>
<td><h3><a href="?action=CopyFile">复制文件</a></h3><h3><a href="?action=GetFile">复制文件</a></h3></td>
<td><h3><a href="?action=DelFile">删除文件</a></h3><h3><a href="?action=msbc">浏览器操作</a></h3></td>
<td><h3><a href="?action=type">文件属性</a></h3><h3><a href="?action=Drive">驱动器操作</a></h3></td>
</tr>
</table>
<h1><a href="?action=infso">查看是否支持FSO</a></h1>
<h3><a href="?action=Folder">对文件夹操作</a></h3>
====================================================================================================<br>
<% action=Trim(Request("action"))
Select Case action
Case "create"
Call FsoFile("main.txt","我在当前的目录创建了一个叫main.txt的文件!")
Case "instrinto"
Call FsoInstrInto("text.txt")
Case "readfile"
Call FsoReadFile("text.txt")
Case "Select"
Call SelectFile("text.txt")
Case "CopyFile"
Call CopyFile("text.txt","textA.txt")
Case "GetFile"
Call GetFiles("text.txt","getfile.txt")
Case "DelFile"
Call DeleteFile("getfile.txt")
Case "msbc"
Call Mswc()
Case "type"
Call FileType("text.txt")
Case "Folder"
Call FsoFolder()
Case "infso"
Call IsFso("Scripting.FileSystemObject")
Case "Drive"
Call Drive("e:")
Case Else
Alert("<font color=red>请选择操作</fnot>")
End Select
%>
</center></body><html>
[此贴子已经被作者于2006-12-9 16:02:57编辑过]