首先需要调用组件:Set FSO = Server.CreateObject("Scripting.FileSystemObject")
生成绝对路径:Path = Server.MapPath(Path)
文件夹的操作:
1.检查文件夹是否存在:FSO.FolderExists(Path)
2.生成一个新的文件夹:FSO.CreateFolder(Path)
3.复制文件夹内容:FSO.CopyFolder Path,NewPath,1
4.移动文件夹:FSO.MoveFolder Path,NewPath
5.删除文件夹:FSO.DeleteFolder(Path)
文件的操作:
1.检查文件是否存在:FSO.FileExists(Path)
2.生成一个新的文件:FSO.CreateTextFile(Path,True)
3.读取文件内容:
Set FS = FSO.OpenTextFile(Path, 1, False)
ConnText=FS.ReadAll
FS.Close
Set FS = Nothing
4.写入文件内容:
Set FS = FSO.CreateTextFile(Path,True)
FS.WriteLine(TextContent) 'FS.Write(TextContent)
FS.Close
Set FS = Nothing
5.移动文件:FSO.MoveFile Path,NewPath
6.删除文件:FSO.DeleteFile(Path)
注:移动文件里的NewPath为文件地址而非文件夹地址,最后使用Set FSO = Nothing 释放资源
fso移动、复制和删除文件
FSO 对象模型各有两种方法移动、复制和删除文件,如下表所述。
移动文件 File.Move 或 FileSystemObject.MoveFile
复制文件 File.Copy 或 FileSystemObject.CopyFile
删除文件 File.Delete 或 FileSystemObject.DeleteFile
posted @
2010-07-19 11:29
ActionBi
阅读(
206)
评论()
收藏
举报