asp中一些fso方面的函数
'//==================================文件操作==================================
'取文件大小
function getfilesize(filename)
'//功能:取文件大小
'//形参:文件名
'//返回值:成功为文件大小,失败为-1
'//
dim f
if reportfilestatus(filename) = 1 then
set f = fso.getfile(filename)
getfilesize = f.size
else
getfilesize = -1
end if
end function
'文件删除
function deleteafile(filespec)
'//功能:文件删除
'//形参:文件名
'//返回值:成功为1,失败为-1
'//
if reportfilestatus(filespec) = 1 then
fso.deletefile(filespec)
deleteafile = 1
else
deleteafile = -1
end if
end function
'显示文件列表
function showfilelist(folderspec)
'//功能:目录存在时显示此目录下的所有文件
'//形参:目录名
'//返回值:成功为文件列表,失败为-1
'//
dim f, f1, fc, s
if reportfolderstatus(folderspec) = 1 then
set f = fso.getfolder(folderspec)
set fc = f.files
for each f1 in fc
s = s & f1.name
s = s & ""
next
showfilelist = s
else
showfilelist = -1
end if
end function
'!!!
'文件复制
function copyafile(sourcefile,destinationfile)
'//功能:源文件存在时,才能对文件进行复制,目的文件无影响
'//形参:源文件,目的文件
'//返回值:成功为1,失败为-1
'//
dim myfile
if reportfilestatus(sourcefile) = 1 then
set myfile = fso.getfile(sourcefile)
myfile.copy (destinationfile)
copyafile = 1
else
copyafile = -1
end if
end function
'文件移动
'response.write moveafile("f:\123\4561.exe","f:\123\4562.txt")
function moveafile(sourcefile,destinationfile)
'//功能:源文件存在时目的文件不存在时才能对文件进行移动
'//形参:源文件,目的文件
'//返回值:成功为1,失败为-1
'//
if reportfilestatus(sourcefile)=1 and reportfilestatus(destinationfileorpath) =
-1 then
fso.movefile sourcefile,destinationfileorpath
moveafile = 1
else
moveafile = -1
end if
end function
'文件是否存在?
'response.write reportfilestatus("g:\soft\delphi\my_pro\代码库.exe")
function reportfilestatus(filename)
'//功能:判断文件是否存在
'//形参:文件名
'//返回值:成功为1,失败为-1
'//
dim msg
msg = -1
if (fso.fileexists(filename)) then
msg = 1
else
msg = -1
end if
reportfilestatus = msg
end function
'文件创建日期
'response.write showdatecreated("g:\soft\delphi\my_pro\代码库.exe")
'response.write showdatecreated("g:\soft\delphi\my_pro\复件 代码库.exe")
function showdatecreated(filespec)
'//功能:文件创建日期
'//形参:文件名
'//返回值:成功:文件创建日期,失败:-1
'//
dim f
if reportfilestatus(filespec) = 1 then
set f = fso.getfile(filespec)
showdatecreated = f.datecreated
else
showdatecreated = -1
end if
end function
'文件属性
'response.write getattributes("g:\soft\delphi\my_pro\复件 代码库.exe")
function getattributes(filename)
'//功能:显示文件属性
'//形参:文件名
'//返回值:成功:文件属性,失败:-1
'//
dim f,str
if reportfilestatus(filename) = 1 then
set f = fso.getfile(filename)
select case f.attributes
case 0 str="普通文件。没有设置任何属性。 "
case 1 str="只读文件。可读写。 "
case 2 str="隐藏文件。可读写。 "
case 4 str="系统文件。可读写。 "
case 16 str="文件夹或目录。只读。 "
case 32 str="上次备份后已更改的文件。可读写。 "
case 1024 str="链接或快捷方式。只读。 "
case 2048 str=" 压缩文件。只读。"
end select
getattributes = str
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器