ASP之FSO函数大全
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
[p]<[color=#0000ff]%[/color][br][color=#ff00ff]'asp中一些fso方面的函数 [/color][br][br][br][color=#ff00ff]'//==================================文件操作================================== [/color][br][br][br][color=#ff00ff]'取文件大小 [/color][br][color=#0000a0][b]function[/b][/color] getfilesize[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:取文件大小 [/color][br][color=#ff00ff]'//形参:文件名 [/color][br][color=#ff00ff]'//返回值:成功为文件大小,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim f [br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfile[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br]getfilesize [color=#0000ff]=[/color] f[color=#0000ff].[/color]size [br]else [br]getfilesize [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'文件删除 [/color][br][color=#0000a0][b]function[/b][/color] deleteafile[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:文件删除 [/color][br][color=#ff00ff]'//形参:文件名 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]if reportfilestatus[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]fso[color=#0000ff].[/color]deletefile[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [br]deleteafile [color=#0000ff]=[/color] 1 [br]else [br]deleteafile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'显示文件列表 [/color][br][color=#0000a0][b]function[/b][/color] showfilelist[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:目录存在时显示此目录下的所有文件 [/color][br][color=#ff00ff]'//形参:目录名 [/color][br][color=#ff00ff]'//返回值:成功为文件列表,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim f[color=#0000ff],[/color] f1[color=#0000ff],[/color] fc[color=#0000ff],[/color] s [br]if reportfolderstatus[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfolder[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br]set fc [color=#0000ff]=[/color] f[color=#0000ff].[/color]files [br]for each f1 [color=#800000][b]in[/b][/color] fc [br]s [color=#0000ff]=[/color] s [color=#0000ff]&[/color] f1[color=#0000ff].[/color]name [br]s [color=#0000ff]=[/color] s [color=#0000ff]&[/color] [color=#ff00ff]"|"[/color] [br]next [br]showfilelist [color=#0000ff]=[/color] s [br]else [br]showfilelist [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'!!! [/color][br][color=#ff00ff]'文件复制 [/color][br][color=#0000a0][b]function[/b][/color] copyafile[color=#0000ff]([/color]sourcefile[color=#0000ff],[/color]destinationfile[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:源文件存在时,才能对文件进行复制,目的文件无影响 [/color][br][color=#ff00ff]'//形参:源文件,目的文件 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim myfile [br]if reportfilestatus[color=#0000ff]([/color]sourcefile[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set myfile [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfile[color=#0000ff]([/color]sourcefile[color=#0000ff])[/color] [br]myfile[color=#0000ff].[/color]copy [color=#0000ff]([/color]destinationfile[color=#0000ff])[/color] [br]copyafile [color=#0000ff]=[/color] 1 [br]else [br]copyafile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'文件移动 [/color][br][color=#ff00ff]'response.write moveafile("f:\123\4561.exe","f:\123\4562.txt") [/color][br][color=#0000a0][b]function[/b][/color] moveafile[color=#0000ff]([/color]sourcefile[color=#0000ff],[/color]destinationfile[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:源文件存在时目的文件不存在时才能对文件进行移动 [/color][br][color=#ff00ff]'//形参:源文件,目的文件 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]if reportfilestatus[color=#0000ff]([/color]sourcefile[color=#0000ff])[/color][color=#0000ff]=[/color]1 and [br]reportfilestatus[color=#0000ff]([/color]destinationfileorpath[color=#0000ff])[/color] [color=#0000ff]=[/color] [br][br][br][color=#0000ff]-[/color]1 then [br]fso[color=#0000ff].[/color]movefile sourcefile[color=#0000ff],[/color]destinationfileorpath [br]moveafile [color=#0000ff]=[/color] 1 [br]else [br]moveafile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'文件是否存在? [/color][br][color=#ff00ff]'response.write reportfilestatus("g:\soft\delphi\my_pro\代码库.exe") [/color][br][color=#0000a0][b]function[/b][/color] reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:判断文件是否存在 [/color][br][color=#ff00ff]'//形参:文件名 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim msg [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]if [color=#0000ff]([/color]fso[color=#0000ff].[/color]fileexists[color=#0000ff]([/color]filename[color=#0000ff])[/color][color=#0000ff])[/color] then [br]msg [color=#0000ff]=[/color] 1 [br]else [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end if [br]reportfilestatus [color=#0000ff]=[/color] msg [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'文件创建日期 [/color][br][color=#ff00ff]'response.write showdatecreated("g:\soft\delphi\my_pro\代码库.exe") [/color][br][color=#ff00ff]'response.write showdatecreated("g:\soft\delphi\my_pro\复件 [/color][br]代码库[color=#0000ff].[/color]exe[color=#ff00ff]") [/color][br][color=#0000a0][b]function[/b][/color] showdatecreated[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:文件创建日期 [/color][br][color=#ff00ff]'//形参:文件名 [/color][br][color=#ff00ff]'//返回值:成功:文件创建日期,失败:-1 [/color][br][color=#ff00ff]'// [/color][br]dim f [br]if reportfilestatus[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfile[color=#0000ff]([/color]filespec[color=#0000ff])[/color] [br]showdatecreated [color=#0000ff]=[/color] f[color=#0000ff].[/color]datecreated [br]else [br]showdatecreated [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'文件属性 [/color][br][color=#ff00ff]'response.write getattributes("g:\soft\delphi\my_pro\复件 [/color][br]代码库[color=#0000ff].[/color]exe[color=#ff00ff]") [/color][br][color=#0000a0][b]function[/b][/color] getattributes[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:显示文件属性 [/color][br][color=#ff00ff]'//形参:文件名 [/color][br][color=#ff00ff]'//返回值:成功:文件属性,失败:-1 [/color][br][color=#ff00ff]'// [/color][br]dim f[color=#0000ff],[/color]str [br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfile[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br]select case f[color=#0000ff].[/color][color=#008000]attributes[/color] [br]case 0 str[color=#0000ff]=[/color][color=#ff00ff]"普通文件。没有设置任何属性。 "[/color] [br]case 1 str[color=#0000ff]=[/color][color=#ff00ff]"只读文件。可读写。 "[/color] [br]case 2 str[color=#0000ff]=[/color][color=#ff00ff]"隐藏文件。可读写。 "[/color] [br]case 4 str[color=#0000ff]=[/color][color=#ff00ff]"系统文件。可读写。 "[/color] [br]case 16 str[color=#0000ff]=[/color][color=#ff00ff]"文件夹或目录。只读。 "[/color] [br]case 32 str[color=#0000ff]=[/color][color=#ff00ff]"上次备份后已更改的文件。可读写。 "[/color] [br]case 1024 str[color=#0000ff]=[/color][color=#ff00ff]"链接或快捷方式。只读。 "[/color] [br]case 2048 str[color=#0000ff]=[/color][color=#ff00ff]" 压缩文件。只读。"[/color] [br]end select [br]getattributes [color=#0000ff]=[/color] str [br]else [br]getattributes [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'最后一次访问/最后一次修改时间 [/color][br][color=#ff00ff]'response.write showfileaccessinfo("g:\soft\delphi\my_pro\复件 [/color][br]代码库[color=#0000ff].[/color]exe[color=#ff00ff]") [/color][br][color=#0000a0][b]function[/b][/color] showfileaccessinfo[color=#0000ff]([/color]filename[color=#0000ff],[/color]infotype[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:显示文件创建时信息 [/color][br][color=#ff00ff]'//形参:文件名,信息类别 [/color][br][color=#ff00ff]'// 1 -----创建时间 [/color][br][color=#ff00ff]'// 2 -----上次访问时间 [/color][br][color=#ff00ff]'// 3 -----上次修改时间 [/color][br][color=#ff00ff]'// 4 -----文件路径 [/color][br][color=#ff00ff]'// 5 -----文件名称 [/color][br][color=#ff00ff]'// 6 -----文件类型 [/color][br][color=#ff00ff]'// 7 -----文件大小 [/color][br][color=#ff00ff]'// 8 -----父目录 [/color][br][color=#ff00ff]'// 9 -----根目录 [/color][br][color=#ff00ff]'//返回值:成功为文件创建时信息,失败:-1 [/color][br][color=#ff00ff]'// [/color][br]dim f[color=#0000ff],[/color] s [br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfile[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br]select case infotype [br]case 1 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datecreated [color=#ff00ff]'// 1 ----- [/color][br][br][br]创建时间 [br]case 2 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datelastaccessed [color=#ff00ff]'// 2 -----上次访问 [/color][br][br][br]时间 [br]case 3 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datelastmodified [color=#ff00ff]'// 3 -----上次修改 [/color][br][br][br]时间 [br]case 4 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]path [color=#ff00ff]'// 4 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件路径 [br]case 5 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]name [color=#ff00ff]'// 5 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件名称 [br]case 6 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]type [color=#ff00ff]'// 6 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件类型 [br]case 7 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]size [color=#ff00ff]'// 7 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件大小 [br]case 8 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]parentfolder [color=#ff00ff]'// 8 ----- [/color][br][br][br]父目录 [br]case 9 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]rootfolder [color=#ff00ff]'// 8 ----- [/color][br][br][br]根目录 [br]end select [br]showfileaccessinfo [color=#0000ff]=[/color] s [br]else [br]showfileaccessinfo [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'写文本文件 [/color][br][color=#0000a0][b]function[/b][/color] writetxtfile[color=#0000ff]([/color]filename[color=#0000ff],[/color]textstr[color=#0000ff],[/color]writeorappendtype[color=#0000ff])[/color] [br]const forreading [color=#0000ff]=[/color] 1[color=#0000ff],[/color] forwriting [color=#0000ff]=[/color] 2 [color=#0000ff],[/color] forappending [color=#0000ff]=[/color] 8 [br]dim f[color=#0000ff],[/color] m [br]select case writeorappendtype [br]case 1[color=#0000ff]:[/color] [color=#ff00ff]'文件进行写操作 [/color][br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]opentextfile[color=#0000ff]([/color]filename[color=#0000ff],[/color] forwriting[color=#0000ff],[/color] true[color=#0000ff])[/color] [br]f[color=#0000ff].[/color]write textstr [br]f[color=#0000ff].[/color]close [br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]writetxtfile [color=#0000ff]=[/color] 1 [br]else [br]writetxtfile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]case 2[color=#0000ff]:[/color] [color=#ff00ff]'文件末尾进行写操作 [/color][br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]opentextfile[color=#0000ff]([/color]filename[color=#0000ff],[/color] forappending[color=#0000ff])[/color] [br]f[color=#0000ff].[/color]write textstr [br]f[color=#0000ff].[/color]close [br]writetxtfile [color=#0000ff]=[/color] 1 [br]else [br]writetxtfile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end select [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'读文本文件 [/color][br][color=#0000a0][b]function[/b][/color] readtxtfile[color=#0000ff]([/color]filename[color=#0000ff])[/color] [br]const forreading [color=#0000ff]=[/color] 1[color=#0000ff],[/color] forwriting [color=#0000ff]=[/color] 2 [br]dim f[color=#0000ff],[/color] m [br]if reportfilestatus[color=#0000ff]([/color]filename[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]opentextfile[color=#0000ff]([/color]filename[color=#0000ff],[/color] forreading[color=#0000ff])[/color] [br]m [color=#0000ff]=[/color] f[color=#0000ff].[/color]readline [br][color=#ff00ff]'m = f.readall [/color][br][color=#ff00ff]'f.skipline [/color][br]readtxtfile [color=#0000ff]=[/color] m [br]f[color=#0000ff].[/color]close [br]else [br]readtxtfile [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'建立文本文件 [/color][br][br][br][color=#ff00ff]'//==================================目录操作================================== [/color][br][br][br][color=#ff00ff]'取目录大小 [/color][br][color=#0000a0][b]function[/b][/color] getfoldersize[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:取目录大小 [/color][br][color=#ff00ff]'//形参:目录名 [/color][br][color=#ff00ff]'//返回值:成功为目录大小,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim f [br]if reportfolderstatus[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfolder[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [br]getfoldersize [color=#0000ff]=[/color] f[color=#0000ff].[/color]size [br]else [br]getfoldersize [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'创建的文件夹 [/color][br][color=#0000a0][b]function[/b][/color] createfolderdemo[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:创建的文件夹 [/color][br][color=#ff00ff]'//形参:目录名 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim f [br]if reportfolderstatus[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]createfolderdemo [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]else [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]createfolder[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [br]createfolderdemo [color=#0000ff]=[/color] 1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'!!! [/color][br][color=#ff00ff]'目录删除 [/color][br][color=#0000a0][b]function[/b][/color] deleteafolder[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:目录删除 [/color][br][color=#ff00ff]'//形参:目录名 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]response[color=#0000ff].[/color]write folderspec [br]if reportfolderstatus[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]fso[color=#0000ff].[/color]deletefolder [color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br]deleteafolder [color=#0000ff]=[/color] 1 [br]else [br]deleteafolder [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'显示目录列表 [/color][br][color=#0000a0][b]function[/b][/color] showfolderlist[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:目录存在时显示此目录下的所有子目录 [/color][br][color=#ff00ff]'//形参:目录名 [/color][br][color=#ff00ff]'//返回值:成功为子目录列表,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim f[color=#0000ff],[/color] f1[color=#0000ff],[/color] fc[color=#0000ff],[/color] s [br]if reportfolderstatus[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfolder[color=#0000ff]([/color]folderspec[color=#0000ff])[/color] [br]set fc [color=#0000ff]=[/color] f[color=#0000ff].[/color]subfolders [br]for each f1 [color=#800000][b]in[/b][/color] fc [br]s [color=#0000ff]=[/color] s [color=#0000ff]&[/color] f1[color=#0000ff].[/color]name [br]s [color=#0000ff]=[/color] s [color=#0000ff]&[/color] [color=#ff00ff]"|"[/color] [br]next [br]showfolderlist [color=#0000ff]=[/color] s [br]else [br]showfolderlist [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'!!!! [/color][br][color=#ff00ff]'目录复制 [/color][br][color=#0000a0][b]function[/b][/color] copyafolder[color=#0000ff]([/color]sourcefolder[color=#0000ff],[/color]destinationfolder[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:源目录存在时,才能对目录进行复制,目的目录无影响 [/color][br][color=#ff00ff]'//形参:源目录,目的目录 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br][color=#ff00ff]'dim myfolder [/color][br][color=#ff00ff]'if reportfolderstatus(sourcefolder) = 1 and reportfolderstatus [/color][br][br][br][color=#0000ff]([/color]destinationfolder[color=#0000ff])[/color] [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 then [br][color=#ff00ff]'set myfolder = fso.getfolder(sourcefolder) [/color][br]fso[color=#0000ff].[/color]copyfolder sourcefolder[color=#0000ff],[/color]destinationfolder [br]copyafolder [color=#0000ff]=[/color] 1 [br][color=#ff00ff]'else [/color][br]copyafolder [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br][color=#ff00ff]'end if [/color][br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'目录进行移动 [/color][br][color=#0000a0][b]function[/b][/color] moveafolder[color=#0000ff]([/color]sourcepath[color=#0000ff],[/color]destinationpath[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:源目录存在时目的目录不存在时才能对目录进行移动 [/color][br][color=#ff00ff]'//形参:源目录,目的目录 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]if reportfolderstatus[color=#0000ff]([/color]sourcepath[color=#0000ff])[/color][color=#0000ff]=[/color]1 and [br]reportfolderstatus[color=#0000ff]([/color]destinationpath[color=#0000ff])[/color][color=#0000ff]=[/color]0 [br][br][br]then [br]fso[color=#0000ff].[/color]movefolder sourcepath[color=#0000ff],[/color] destinationpath [br]moveafolder [color=#0000ff]=[/color] 1 [br]else [br]moveafolder [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'判断目录是否存在 [/color][br][color=#ff00ff]'response.write reportfolderstatus("g:\soft\delphi\my_pro\") [/color][br][color=#0000a0][b]function[/b][/color] reportfolderstatus[color=#0000ff]([/color]fldr[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:判断目录是否存在 [/color][br][color=#ff00ff]'//形参:目录 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim msg [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]if [color=#0000ff]([/color]fso[color=#0000ff].[/color]folderexists[color=#0000ff]([/color]fldr[color=#0000ff])[/color][color=#0000ff])[/color] then [br]msg [color=#0000ff]=[/color] 1 [br]else [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end if [br]reportfolderstatus [color=#0000ff]=[/color] msg [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'目录创建时信息 [/color][br][color=#0000a0][b]function[/b][/color] showfolderaccessinfo[color=#0000ff]([/color]foldername[color=#0000ff],[/color]infotype[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:显示目录创建时信息 [/color][br][color=#ff00ff]'//形参:目录名,信息类别 [/color][br][color=#ff00ff]'// 1 -----创建时间 [/color][br][color=#ff00ff]'// 2 -----上次访问时间 [/color][br][color=#ff00ff]'// 3 -----上次修改时间 [/color][br][color=#ff00ff]'// 4 -----目录路径 [/color][br][color=#ff00ff]'// 5 -----目录名称 [/color][br][color=#ff00ff]'// 6 -----目录类型 [/color][br][color=#ff00ff]'// 7 -----目录大小 [/color][br][color=#ff00ff]'// 8 -----父目录 [/color][br][color=#ff00ff]'// 9 -----根目录 [/color][br][color=#ff00ff]'//返回值:成功为目录创建时信息,失败:-1 [/color][br][color=#ff00ff]'// [/color][br]dim f[color=#0000ff],[/color] s [br]if reportfolderstatus[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfolder[color=#0000ff]([/color]foldername[color=#0000ff])[/color] [br]select case infotype [br]case 1 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datecreated [color=#ff00ff]'// 1 ----- [/color][br][br][br]创建时间 [br]case 2 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datelastaccessed [color=#ff00ff]'// 2 -----上次访问 [/color][br][br][br]时间 [br]case 3 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]datelastmodified [color=#ff00ff]'// 3 -----上次修改 [/color][br][br][br]时间 [br]case 4 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]path [color=#ff00ff]'// 4 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件路径 [br]case 5 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]name [color=#ff00ff]'// 5 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件名称 [br]case 6 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]type [color=#ff00ff]'// 6 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件类型 [br]case 7 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]size [color=#ff00ff]'// 7 [/color][br][br][br][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color][color=#0000ff]-[/color]文件大小 [br]case 8 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]parentfolder [color=#ff00ff]'// 8 ----- [/color][br][br][br]父目录 [br]case 9 s [color=#0000ff]=[/color] f[color=#0000ff].[/color]rootfolder [color=#ff00ff]'// 9 ----- [/color][br][br][br]根目录 [br]end select [br]showfolderaccessinfo [color=#0000ff]=[/color] s [br]else [br]showfolderaccessinfo [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#0000a0][b]function[/b][/color] displayleveldepth[color=#0000ff]([/color]pathspec[color=#0000ff])[/color] [br]dim f[color=#0000ff],[/color] n [color=#0000ff],[/color]path [br]set f [color=#0000ff]=[/color] fso[color=#0000ff].[/color]getfolder[color=#0000ff]([/color]pathspec[color=#0000ff])[/color] [br]if f[color=#0000ff].[/color]isrootfolder then [br]displayleveldepth [color=#0000ff]=[/color][color=#ff00ff]"指定的文件夹是根文件夹。"[/color][color=#0000ff]&[/color]rootfolder [br]else [br]do until f[color=#0000ff].[/color]isrootfolder [br]path [color=#0000ff]=[/color] path [color=#0000ff]&[/color] f[color=#0000ff].[/color]name [color=#0000ff]&[/color][color=#ff00ff]"
"[/color] [br]set f [color=#0000ff]=[/color] f[color=#0000ff].[/color]parentfolder [br]n [color=#0000ff]=[/color] n [color=#0000ff]+[/color] 1 [br]loop [br]displayleveldepth [color=#0000ff]=[/color][color=#ff00ff]"指定的文件夹是嵌套级为 "[/color] [color=#0000ff]&[/color] n [color=#0000ff]&[/color] [color=#ff00ff]" [/color][br]的文件夹。[color=#0000ff]<[/color]br[color=#0000ff]>[/color][color=#ff00ff]"& [/color][br][br][br]path [br]end if [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'//==================================磁盘操作================================== [/color][br][color=#ff00ff]'驱动器是否存在? [/color][br][color=#ff00ff]'response.write reportdrivestatus("c:\") [/color][br][color=#0000a0][b]function[/b][/color] reportdrivestatus[color=#0000ff]([/color]drv[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:判断磁盘是否存在 [/color][br][color=#ff00ff]'//形参:磁盘 [/color][br][color=#ff00ff]'//返回值:成功为1,失败为-1 [/color][br][color=#ff00ff]'// [/color][br]dim msg [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]if fso[color=#0000ff].[/color]driveexists[color=#0000ff]([/color]drv[color=#0000ff])[/color] then [br]msg [color=#0000ff]=[/color] 1 [br]else [br]msg [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end if [br]reportdrivestatus [color=#0000ff]=[/color] msg [br]end [color=#0000a0][b]function[/b][/color] [br][br][br][color=#ff00ff]'--------可用的返回类型包括 fat、ntfs 和 cdfs。 [/color][br][color=#ff00ff]'response.write showfilesystemtype("c:\") [/color][br][color=#0000a0][b]function[/b][/color] showfilesystemtype[color=#0000ff]([/color]drvspec[color=#0000ff])[/color] [br][color=#ff00ff]'//功能:磁盘类型 [/color][br][color=#ff00ff]'//形参:磁盘名 [/color][br][color=#ff00ff]'//返回值:成功为类型:fat、ntfs 和 cdfs,失败:-1 [/color][br][color=#ff00ff]'// [/color][br]dim d [br]if reportdrivestatus[color=#0000ff]([/color]drvspec[color=#0000ff])[/color] [color=#0000ff]=[/color] 1 then [br]set d [color=#0000ff]=[/color] fso[color=#0000ff].[/color] getdrive[color=#0000ff]([/color]drvspec[color=#0000ff])[/color] [br]showfilesystemtype [color=#0000ff]=[/color] d[color=#0000ff].[/color]filesystem [br]else [br]showfilesystemtype [color=#0000ff]=[/color] [color=#0000ff]-[/color]1 [br]end [color=#800000][b]if[/b][/color] [br]end [color=#0000a0][b]function[/b][/color] [br][color=#0000ff]%[/color][color=#0000ff]>[/color] [/p] 该文章在 2010/7/22 21:58:40 编辑过 |
关键字查询
相关文章
正在查询... |