FSO文本文件操作,读取一个文件相关信息$
来源:互联网 发布:校园网络逻辑拓扑图 编辑:程序博客网 时间:2024/05/22 12:06
FSO读取一个文件相关信息的范例
<% Dim objFSO,objFile ’声明一个名称为 objFSO 的变量以存放对象实例 Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(Server.MapPath("newfile.asp")) Then Set objFile = objFSO.GetFile(Server.MapPath("newfile.asp")) Response.Write "文件的名称:"&objFile.Name&"<br>" Response.Write "文件的路径:"&objFile.Path&"<br>" Response.Write "文件的建立日期:"&objFile.DateCreated&"<br>" Response.Write "文件的最后浏览日期:"&objFile.DateLastAccessed&"<br>" Response.Write "文件的最后修改日期:"&objFile.DateLastModified&"<br>" Response.Write "文件的大小:"&objFile.Size&"<br>" Response.Write "文件的类型:"&objFile.Type&"<br>" Else Response.Write Server.MapPath("newfile.asp")&"不存在,无法读取相关信息" End If Set objFile = Nothing Set objFSO = Nothing ’释放 FileSystemObject 对象实例内存空间 %>
<HTML><HEAD><TITLE>My FileSystemObject Sample Page</TITLE></HEAD><BODY><%'Constants for Script parametersdim ForReading = 1dim ForWriting = 2dim ForAppending = 8' Newline var consists of HTML <BR> tag plus a JScript newline.dim NewLine = "<BR>\n"' (1)Create a FileSystemObject.dim fso, tsset fso = Server.CreateObject("Scripting.FileSystemObject")'(2)Create a new TextStream object using FSO, and write to it.'This results in a new file.set ts = fso.CreateTextFile("c:\fileshare\test.txt",true)ts.WriteLine("Hello World!")ts.WriteBlankLines(1)ts.WriteLine("This is my first FileSystemObject application.")ts.Close' (3)Access an existing file and its attributes--Name, Path, and DateLastModified.set ts = fso.GetFile("c:\fileshare\test.txt")Response.Write("Your file's name is: " + ts.Name + NewLine)Response.Write("Your file's path is: " + ts.Path + NewLine)Response.Write("File last changed: " + ts.DateLastModified)'(4)Open the file and read data from it. Notice that when you call'OpenTextFile, you set the overwrite parameter to "false," so you 'use the existing file instead of creating a new one.strFil = NewLine + ""set ts = fso.OpenTextFile("c:\fileshare\test.txt",ForReading,false)' (5)Loop through lines in the file, read them into strFil variable.while not ts.AtEndOfStream strFil = strFil & ts.ReadLine + NewLinewend'Write the variable containing the file contents into the page.Response.Write(NewLine + strFil)ts.Closeset fso=nothing%></BODY></HTML>
- FSO文本文件操作,读取一个文件相关信息$
- FSO读取一个文件相关信息的范例
- 如何从一个文件特定段落中(文本文件),读取相关的文件信息,并进行分段梳理
- #读取一个文件相关信息的范例
- 用ADODB.Stream代替FSO读取文本文件
- 用ADODB.Stream代替FSO读取文本文件
- 用ADODB.Stream代替FSO读取文本文件
- 用ADODB.Stream代替FSO读取文本文件
- 一个简单的文件操作,将系统信息写入到一个文本文件
- C文件操作示例:逐行读取文本文件
- FSO文件操作类
- ASP FSO文件操作
- ASP FSO文件操作
- matlab文件读取相关操作
- Javascript操作文件(FSO)
- Javascript操作文件(FSO)
- ASP文件操作(FSO)详解
- ASP文件操作(FSO)详解
- dsPIC33F单片机产生正弦波形
- 写ASP采集的一些函数
- 【TCP/IP详解】第3章 IP:网际协议
- 【jiasuba】Word2010启动一直没响应,如何解决?
- 如何提高英文的科研写作能力
- FSO文本文件操作,读取一个文件相关信息$
- 冒泡排序
- 网页JS简繁体字转换
- 【TCP/IP详解】第4章 ARP:地址解析协议
- 小米手机的售后让我伤心让我恨!!
- STM32 从用户程序中启动 BootLoader
- 献给最美好的大学时光
- QT 实现字幕滚动(上下滚动)
- API函数MoveFileEx使用详解(delphi)