当前位置: 网学 > 编程文档 > ASP > 正文

FSO操作文件系统

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17
der,xmlfile,content,mode)
writeto=false
If Not IsObjInstalled(theInstalledObjects(9)) Then Exit Function
mode=killint(mode,0,0,2)
xmlfloder=server.mappath(xmlfloder)
Set fso =Server.CreateObject("Scripting.FileSystemObject")
if not fso.folderexists(xmlfloder) Then
fso.createfolder(xmlfloder)
End If
xmlfile=replace(xmlfloder&"\","\\","\")&xmlfile
'' response.write(warn_red(xmlfile))
Dim fsoxml
If fso.fileexists(xmlfile) And mode=1 Then ''存在不写
Exit Function
elseIf fso.fileexists(xmlfile) And mode=2 Then ''重写
Set fsoxml=fso.opentextfile(xmlfile,2)
fsoxml.writeline(content)
fsoxml.close
writeto=true
ElseIf fso.fileexists(xmlfile) And mode=8 Then ''追加
Set fsoxml=fso.opentextfile(xmlfile,8)
fsoxml.writeline(content)
fsoxml.close
writeto=true
ElseIf fso.fileexists(xmlfile) Then
Set fsoxml=fso.opentextfile(xmlfile,2)''重写
fsoxml.writeline(content)
fsoxml.close
writeto=true
Else
Set fsoxml=fso.createtextfile(xmlfile)''创建
fsoxml.writeline(content)
fsoxml.close
writeto=true
End If
End Function
''删除文件
Function delaspfile(x)
On Error Resume Next
delaspfile=False
If Not fileexitornot(x) Then
Exit Function
Else
fso.deletefile server.mappath(x)
delaspfile=True
End if
End Function
''文件存在
Function fileexitornot(file)
On Error Resume Next
Dim f_re_file
f_re_file=true
If not fso.fileexists(server.MapPath(file)) Then f_re_file=False
If err<>0 Then f_re_file=False
fileexitornot=f_re_file
End Function

''错误抑制,打印错误
Function show_err(err)
On Error Resume Next
If err.Number <> 0 Then
Response.Clear
Dim err_mess
err_mess="<b>发生错误:</b><br/>错误 Number: "& err.Number&"<br/>错误信息:"&err.Description&"<br/>出错文件:"&err.Source&"<br/>出错行:"&err.Line&"(不被支持)<br/>"& err
response.write(err_mess)
End if
End Function
''警告:
Function warn_red(mess)
warn_red="<font color=red><b>跟踪:"&mess&"</b></font><br/>"
End Function


''FSO文件目录
Function showallfile(path)
''On Error Resume Next
path=Replace(path,"//","/")
set fso = CreateObject("Scripting.FileSystemObject")
Dim uploadPath,uploadfolder,objSubFolders,allfiles,fileitem,objSubFolder,
sFileName
If InStr(1,path,":\")=0 Then
path=Replace(path,"\","/")
uploadPath = server.mappath(path)
Else
path=Replace(path,"/","\")
uploadPath=path
End If
response.write(warn_red(uploadPath))
if not fso.folderexists(uploadPath) Then
response.write warn_red("路径查找失败")
Exit Function
End If
Set uploadfolder = fso.GetFolder(uploadPath)
If uploadfolder.isrootfolder Then
response.write("<b>根目录</b><br/>")
Else
response.write("<b><font color=""#00008b"">父目录:</font><a href=""default.asp?action=fso&this=top&path="&uploadfolder.parentfolder&""">
"&uploadfolder.parentfolder&" </a></b><br/>")

End If
response.write("<b>目录大小:"&int(uploadfolder.size/1024)&" KB</b><br/>")
set objSubFolders=up

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号