<% whichfile=Server.MapPath("cnbruce.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.CreateTextFile(whichfile,true) f1.Write ("This is a test.My Name is cnbruce.") f1.Close Set f2 = fso.GetFile(whichfile)
s = "文件名称:" & f2.name & "<br>" s = s & "文件短路径名:" & f2.shortPath & "<br>" s = s & "文件物理地址:" & f2.Path & "<br>" s = s & "文件属性:" & f2.Attributes & "<br>" s = s & "文件大小: " & f2.size & "<br>" s = s & "文件类型: " & f2.type & "<br>" s = s & "文件创建时间: " & f2.DateCreated & "<br>" s = s & "最近访问时间: " & f2.DateLastAccessed & "<br>" s = s & "最近修改时间: " & f2.DateLastModified response.write(s) %>
<% whichfile=Server.MapPath("cnbruce.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.CreateTextFile(whichfile,true) f1.Write ("This is a test.My Name is cnbruce.") f1.Close Set f2 = fso.GetFile(whichfile) f2.Move "C:\" %> <a href="C:\">查看下有没有</a>
简单的剪切粘贴的功能实现。
三,File.Copy 同样属于fso.GetFile后的一个应用。就只是单纯地拷贝文件到某位置。
3,copyfile.asp
<% whichfile=Server.MapPath("cnbruce.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.CreateTextFile(whichfile,true) f1.Write ("This is a test.My Name is cnbruce.") f1.Close Set f2 = fso.GetFile(whichfile) f2.Copy "D:\" %> <a href="D:\">查看下有没有</a>
和本ASP页面同在目录下的cnbruce.txt文件依然存在。
四,file.Delete 很显然,就是直接删除文件了。
4,delfile.asp
<% whichfile=Server.MapPath("cnbruce.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.CreateTextFile(whichfile,true) f1.Write ("This is a test.My Name is cnbruce.") f1.Close Set f2 = fso.GetFile(whichfile) f2.move "d:\" Set f3 = fso.GetFile("d:\cnbruce.txt") f3.delete %> <a href="d:\">查看下是没有该文件的</a>