预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共34页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

ASP的内置组件ASP组件概述文件存取组件FileSystemObject对象的方法TextStream对象的属性与方法新建文本文件新建文本文件例文本文件的读取或添加文本文件的读取或添加(续)逐行读取并显示文本文件对文本文件添加内容文本的复制、移动和删除<%DimFileObject'定义一个FileSystemObject对象实例SetFileObject=Server.CreateObject("Scripting.FileSystemObject")DimSourceFileDestiFile'定义源文件和目标文件变量SourceFile="c:\inetpub\wwwroot\asptemp\chapter8\test.txt"DestiFile="c:\inetpub\wwwroot\asptemp\chapter8\test2.txt"FileObject.CopyFileSourceFileDestiFileSourceFile="c:\inetpub\wwwroot\asptemp\chapter8\test2.txt"DestiFile="c:\inetpub\wwwroot\asptemp\chapter8\temp\test2.txt"FileObject.MoveFileSourceFileDestiFileSourceFile="c:\inetpub\wwwroot\asptemp\chapter8\temp\test2.txt"IFFileObject.FileExists(SourceFile)ThenFileObject.DeleteFileSourceFileEndIf%>文本夹的新建立、复制、移动和删除<%DimFileObject'定义一个FileSystemObject对象实例SetFileObject=Server.CreateObject("Scripting.FileSystemObject")DimSourceFolderDestiFolder'定义源文件夹和目标文件夹变量'新建文件夹---新建new1文件夹SourceFolder="c:\inetpub\wwwroot\asptemp\chapter8\new1"FileObject.CreateFolderSourceFolder'复制文件夹---将new1复制为new2文件夹SourceFolder="c:\inetpub\wwwroot\asptemp\chapter8\new1"DestiFolder="c:\inetpub\wwwroot\asptemp\chapter8\new2"FileObject.CopyFolderSourceFolderDestiFolder'移动文件夹---将new2文件夹移动到new1下SourceFolder="c:\inetpub\wwwroot\asptemp\chapter8\new2"DestiFolder="c:\inetpub\wwwroot\asptemp\chapter8\new1\new2"FileObject.MoveFolderSourceFolderDestiFolder'删除文件夹---如存在将new2文件夹删除SourceFolder="c:\inetpub\wwwroot\asptemp\chapter8\new1\new2"IFFileObject.FolderExists(SourceFolder)ThenFileObject.DeleteFolderSourceFolderEndIf%>显示文本夹下的所有内容<%DimmyFileObject'定义一个FileSystemObject对象实例DimmyFolder'定义一个Folder对象SetmyFileObject=Server.CreateObject("Scripting.FileSystemObject")'GetFolder方法将返回一个Folder对象SetmyFolder=myFileObject.GetFolder("d:\plan")Response.Write"d:\plan子文件夹如下:<br>"ForEachItemInmyFolder.SubFoldersResponse.WriteItem&"<br>"NextResponse.Write"d:\plan子文件如下:<br>"ForEachItemInmyFolder.F