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

ASP中FSO建立、删除、移动目录和文件的常用函数

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式

ASP的FSO常用操作函数。全部使用相对路径!

Const ObjFSO = "Scripting.FileSystemObject"

Rem 建立目录
Function LjfCreateFolder(Foldername)
 Dim fso
 If Foldername <> "" Then
  Foldername = Server.MapPath(Foldername)
  Set fso = Server.CreateObject(ObjFSO)  
  If fso.FolderExists(Foldername) = False Then 
   fso.CreateFolder Foldername
   LjfCreateFolder = "Ok"
  Else
   LjfCreateFolder = "FolderExists"
  End If
  Set fso = Nothing
 End If 
End Function

Rem 删除目录
Function LjfDeleteFolder(Foldername)
 Dim fso
 If Foldername <> "" Then
  Foldername = Server.MapPath(Foldername)
  Set fso = Server.CreateObject(ObjFSO)
  If fso.FolderExists(Foldername) Then
   fso.DeleteFolder Foldername
   LjfDeleteFolder = "Ok"
  Else
   LjfDeleteFolder = "NoFolder"
  End If
  Set fso = Nothing
 End If
End Function

Rem 移动目录,参数:DirName; 预拷贝文件的相对路径,DirNewName 拷贝目标名
Function LjfMoveFolder(FolderName,FolderNewName)
 Dim fso,f
 If FolderName <> "" And FolderNewName <> "" Then
  FolderName = Server.MapPath(FolderName)
  FolderNewName = Server.MapPath(FolderNewName)
  Set fso = Server.CreateObject(ObjFSO)   
  fso.MoveFolder FolderName,FolderNewName
  Set fso = Nothing
  LjfMoveFolder = "Ok"
 End If
End Function

Rem 建立文件
Function LjfCreateFile(Filename)
 Dim fso
 If Filename <> "" Then
  Filename = Server.MapPath(Filename)
  Set fso = Server.CreateObject(ObjFSO)  
  If fso.FileExists(Filename) = False Then 
   fso.CreateTextFile Filename
   LjfCreateFile = "Ok"
  Else
   LjfCreateFile = "FileExists"
  End If
  Set fso = Nothing
 End If 
End Function
 
Rem 删除文件
Function LjfDeleteFile(Filename)
 Dim fso
 If Filename <> "" Then
  Filename = Server.MapPath(Filename)
  Set fso = Server.CreateObject(ObjFSO)
  If fso.FileExists(Filename) Then
   fso.DeleteFile Filename
   LjfDeleteFile = "Ok"
  Else
   LjfDeleteFile = "NoFile"
  End If
  Set fso = Nothing
 End If
End Function

Rem 移动文件,参数:Filename 预拷贝文件的相对路径,Filenewname 拷贝目标名
Function LjfMoveFile(FileName,FileNewName)
 Dim fso,f
 If Filename <> "" And FileNewName <> "" Then
  FileName = Server.MapPath(FileName)
  FileNewName = Server.MapPath(FileNewName)
  Set fso = Server.CreateObject(ObjFSO)   
  fso.MoveFile FileName,FileNewName
  Set fso = Nothing
  LjfMoveFile = "Ok"
 End If
End Function
 

  • 上一篇资讯: IIS发生意外错误0x8ffe2740
  • 下一篇资讯: asp连接Excel的方法
  • 网学推荐

    免费论文

    原创论文

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