<%
'----------------------------------------------------------------------
'转发时请保留此声明信息,这段声明不并会影响你的速度!
'*******************         DOSASP类 V1.01        ************************************
'作者:九五
'网站:http://dosasp.fanhei.net 您可以从http://fanhei.net/dosasp/dosasp.rar下载到最新版本
'电子邮件:zhaoyao83@hotmail.com
'版权声明:版权所有,源代码公开,各种用途均可免费使用,但是修改后必须把修改后的文件
'发送一份给作者.并且保留作者此版权信息
'**********************************************************************
'----------------------------------------------------------------------
'----------------------------------------------------------------------
Class DosAsp

Public fso
Private Sub Class_Initialize
Set fso=Server.createobject("Scripting.FileSystemObject")
End Sub

'-----------------------------
Public Function Exists(Path) '判断文件目录是否存在
Exists=fso.FileExists(Path)
if not(Exists) then
Exists=fso.FolderExists(Path)
end if
End Function
'------------------------------
Public Function Del(FullPath) '删除文件
        Del=False
        If Exists(FullPath) then
                On error resume next
                fso.DeleteFile(FullPath)
                        if err.number=0 then
                                Del=True
                        End if
        End If
End Function
'------------------------------
Public Function Copy(SourceFile,DestinationFile)'复制文件
        Dim MyFile
        If ReportFileStatus(SourceFile) = 1 Then
            Set MyFile = fso.GetFile(SourceFile)
            MyFile.Copy (DestinationFile)
            CopyAFile = 1
        Else
            CopyAFile = -1
        End If
End Function
'------------------------------
Public Function Md(FullPath) '建立目录
        If Exists(FullPath) Then
            md = false
        Else
            fso.CreateFolder(FullPath)'此处可用set获得目录路径
            md = true
        End If
End Function
'------------------------------------
Public Function Rd(FullPath) '删除目录
        If not(Exists(FullPath)) Then
            rd = false
        Else
            fso.DeleteFolder(FullPath)
            Rd = true
        End If
End Function

'------------------------------------
Public Function Cd(Path) '切换目录
If exists(Path) then
set Cd=fso.GetFolder(Path)
End If
End Function
'----------------------------------
Public Function Ren(MyOld,MyNew) '文件目录重命名
Ren=False
Dim File
If exists(MyOld) then
if instr(MyNew,"\")>0 then
MyNew = Right(s, Len(s) - (InStrRev(MyNew, "\", -1, vbTextCompare)))
end if
on error resume next
set File=fso.GetFile(MyOld)
File.Name=MyNew
if err.number=0 then
Ren=True
end if
err.clear
End If
'```````````````````````````````````````````````
if Ren=False then
If exists(MyOld) then
if instr(MyNew,"\")>0 then
Dir2 = Right(s, Len(s) - (InStrRev(MyNew, "\", -1, vbTextCompare)))
end if
on error resume next
set mDir=Cd(MyOld)
mDir.Name=MyNew
if err.number=0 then
Ren=True
end if
End If
end if
End Function

'------------------------------------
Public    Function Dir(Path) '列目录
        Dim f, f1, fc, s,flag
        If Exists(Path)  Then
            Set f = Cd(Path)
            Set fc = f.SubFolders
                flag=0
            For Each f1 in fc
             flag=flag+1
                if flag<>1 then
                s = s & "|"
                end if
                   s = s & f1.name
            Next
                Flag=0
                set fc=f.Files
                For Each f1 in fc
                flag=flag+1
                if len(s)=0 then
                if flag<>1 then
                           s = s & "|"
                   end if
                else
                        s=s & "|"
                end if       
                   s = s & f1.name
                Next
            Dir = s
        Else
            Dir = False
        End If
    End Function
       
Public Sub MsgBox(MyStr)
        Response.write "<Script language=vbscript> MsgBox("""
        Response.write MyStr
        Response.write """)</Script>"
End Sub

Private Sub Class_Terminate       
        if isobject(fso) then
                set fso=nothing
        end if
End Sub
End Class
%>
Ex:
Set dos=new DosAsp
dos.msgbox(dos.exists(server.mappath("a")))'判断目录a是否存在,并弹出一个对话框
Set dos=nothing

只要有fso权限就可以运行

转载于:https://www.cnblogs.com/MaxIE/archive/2006/03/27/360457.html

fso封装类可以用仿dos命令操作文件相关推荐

  1. 简单的DOS命令操作数据库

    简单的DOS命令操作数据库 启动服务:net start 数据库服务名字 关闭服务:net stop 数据库服务名字 连接数据库:mysql -u用户名 -p密码 show databases -- ...

  2. DOS命令操作大全和计算机运行命令(初次写请多多关照)

    DOS命令操作大全和计算机运行命令 第一次写博客多多关照 写的可能会很杂 不全 DOS结束进程 根据程序名结束: taskkill /f /im xxxx.exe(程序名必须加.exe) 根据程序的P ...

  3. dos命令删除文件夹和文件的方法

    在dos命令删除文件夹或文件,先要确定文件夹或文件是否有特殊的属性,比如"系统"."只读"."隐藏",如果有,去掉这些属性,命令如下 文件夹 ...

  4. dos如何访问服务器文件,如何利用DOS命令将文件上传到服务器

    在天下网吧-网吧系统-网吧天下栏目上一篇文章中,我们看到了:希望对各位网吧网管或者网吧维护,做网吧系统的各位大大有用,那么今天我们一起来看下:如何利用DOS命令将文件上传到服务器 在前面的文章中我们曾 ...

  5. FTP通过DOS命令下载文件到本地

    FTP通过DOS命令下载文件到本地 在用FTP进行操作中的过程,发现网上没有,实际的操作步骤,自己就一边学习一边将学习过程进行记录,以后遇到和我一样问题的,可以进行参考一下,我以后也可以查阅自己的学习 ...

  6. Window用dos命令解压缩文件

    在Windows电脑桌面上,压缩或解压文件是很方便的.但是,有时我们只能通过Dos窗口连接到电脑,这时我们可以通过以下DOS命令处理文件的解压缩. 解压缩的前提是,我们用到WinRAR软件,如果系统没 ...

  7. 用dos复制文件_一文带你熟悉DOS命令操作,CMD从此不再是路人!

    DOS常用命令: 1. 什么是DOS命令,如何打开dos窗口? A:首先:DOS命令是在DOS窗口输入的一系列命令,通过执行这些命令我们可以完成文件的新建.编辑.保存等操作. 打开DOS命令有两种方式 ...

  8. html仿命令行界面,实战:vue仿dos命令界面

    欢迎关注前端小讴的github,原创技术文章 业务需求 vue项目中弹出窗口,在窗口中执行dos命令 技术栈vue + nodejs(child_process+koa) child_process是 ...

  9. 一、SQL Server2017 数据库 基本概念和配置(dos命令操作sql)

    1.数据库的基本概念 硬盘:永久存储 内存:临时存储 数据库:数据仓库 表:货架 2.dos下操作sql 服务:监听端口 关闭服务:net stop mssqlserver 开启服务:net star ...

最新文章

  1. 网络yum网址:http://mirrors.163.com/.help/
  2. Silverlight实用窍门系列:66.Silverlight的数据模板DataTemplate(二)获取数据模板控件...
  3. 袁崇焕·任志强·张纪中
  4. 2.3 指数加权平均-深度学习第二课《改善深层神经网络》-Stanford吴恩达教授
  5. ajax长轮询的问题,Ajax长轮询
  6. 吃透web前端秘籍,来听听大佬是怎么说的
  7. python进程间通信总结_进程间通信方式总结(优缺点)
  8. if语句使用说明(Java)
  9. Ubuntu之安装摄像头软件GTK_UVC_Viewer
  10. 劲爆!Java 通用泛型要来了。。
  11. html同时用多个css,多类选择器的运用_html/css_WEB-ITnose
  12. maya2022|autodesk maya 2022新功能介绍
  13. 出口法和出口管制小记
  14. 【Monkey Run】Excel编程 VBA
  15. 为什么计算机要更新,为什么要关闭windows 10更新理由详解
  16. 我是一个计算机作文,我是一台电脑作文
  17. PBOC/EMV之持卡人验证
  18. 基于SSM框架的图书馆借阅管理系统
  19. 简洁、快速的JavaScript框架/库:jQuery
  20. Unity 3D网页游戏产品展示

热门文章

  1. [Cocos2d-x]Cocos2d-x 3.2 学习笔记
  2. Android 获取系统或SDCARD剩余空间信息(转)
  3. Qt控件中的属性sizePolicy说明
  4. 6月全球Web服务器市场份额:Apache升至64.33%
  5. APUE读书笔记-15进程内部通信-05FIFOs
  6. rsync 服务器文件同步备份
  7. ZooKeeper(四) 使用Redis RedissonLock 实现分布式锁
  8. python3正式发布时间_Python3 日期和时间
  9. Golang的协程池设计
  10. python--采集1(urllib模块)