asp下利用fso实现文件夹或文件移动改名等操作函数_应用技巧

asp利用fso实现文件的移动
function movefiles(sFolder,dFolder)
    on error resume next
    dim fso
    set fso = server.createobject("scripting.filesystemobject")
    if fso.folderexists(server.mappath(sFolder)) and fso.folderexists(server.mappath(dFolder)) then
        fso.copyfolder server.mappath(sFolder),server.mappath(dFolder)
        movefiles = true
    else
        movefiles = false
        set fso = nothing
        call alertbox("系统没有找到指定的路径[" & sFolder & "]!",2)
    end if
    set fso = nothing
end function
asp修改文件夹名称
function renamefolder(sFolder,dFolder)
    on error resume next
    dim fso
    set fso = server.createobject("scripting.filesystemobject")
    if fso.folderexists(server.mappath(sFolder)) then
        fso.movefolder server.mappath(sFolder),server.mappath(dFolder)
        renamefolder = true
    else
        renamefolder = false
        set fso = nothing
        call alertbox("系统没有找到指定的路径[" & sFolder & "]!",2)
    end if
    set fso = nothing
end function
asp检查文件夹是否存在
function checkfolder(sPATH)
    on error resume next
    dim fso
    set fso = server.createobject("scripting.filesystemobject")
    if fso.folderexists(server.mappath(sPATH)) then
        checkfolder = true
    else
        checkfolder = false
    end if
    set fso = nothing
end function
asp检查文件是否存在
function checkfile(sPATH)
    on error resume next
    dim fso
    set fso = server.createobject("scripting.filesystemobject")
    if fso.fileexists(server.mappath(sPATH)) then
        checkfile = true
    else
        checkfile = false
    end if
    set fso = nothing
end function
asp创建文件夹
function createdir(sPATH)
    dim fso,pathArr,i,path_Level,pathTmp,cPATH
    on error resume next
    sPATH = replace(sPATH,"\","/")
    set fso = server.createobject("scripting.filesystemobject")
        pathArr = split(sPATH,"/")
        path_Level = ubound(pathArr)
        for i = 0 to path_Level
            if i = 0 then pathTmp = pathArr(0) & "/" else pathTmp = pathTmp&pathArr(i) & "/"
            cPATH = left(pathTmp,len(pathTmp)-1)
            if not fso.folderexists(cPATH) then fso.createfolder(cPATH)
        next
    set fso = nothing
    if err.number <> 0 then
        err.clear
        createdir = false
    else
        createdir = true
    end if
end function
删除文件夹,这里是删除系统中栏目的文件夹
function delclassfolder(sPATH)
    on error resume next
    dim fso
    set fso = server.createobject("scripting.filesystemobject")
    if fso.folderexists(server.mappath(sPATH)) then
        fso.deletefolder(server.mappath(sPATH))
    end if
    set fso = nothing
end function
删除新闻内容文件
function delnewsfile(sPATH,filename)
    on error resume next
    dim fso,tempArr,cPATH,ePATH,i:i = 0
    set fso = server.createobject("scripting.filesystemobject")
    sPATH = sPATH & filename & site_extname
    if fso.fileexists(server.mappath(sPATH)) then
        fso.deletefile(server.mappath(sPATH))
        while(i <> -1)
            i = i + 1
            ePATH = replace(sPATH,filename & ".",filename & "_" & i + 1 & ".")
            if fso.fileexists(server.mappath(ePATH)) then
                fso.deletefile(server.mappath(ePATH))
            else
                i = -1
            end if
        wend
    end if
end function

时间: 2024-08-03 23:14:55

asp下利用fso实现文件夹或文件移动改名等操作函数_应用技巧的相关文章

asp下利用fso实现文件夹或文件移动改名等操作函数

asp利用fso实现文件的移动 function movefiles(sFolder,dFolder)     on error resume next     dim fso     set fso = server.createobject("scripting.filesystemobject")     if fso.folderexists(server.mappath(sFolder)) and fso.folderexists(server.mappath(dFolder

asp教程:利用fso获取文件名和获取文件或文件夹

获取文件名 这个例子演示如何使用GetFileName方法获取文件名的最后部分中指定的路径. 我们来看个fso获取文件名的实例吧. <html> <body> <% Set fs=Server.CreateObject("Scripting.FileSystemObject") Response.Write("The file name of the last component is: ") Response.Write(fs.Get

asp.net遍历文件夹下所有子文件夹并绑定到gridview上的方法_实用技巧

遍历文件夹下所有子文件夹,并且遍历配置文件某一节点中所有key,value并且绑定到GridView上 Helper app_Helper = new Helper(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); protected void Page_Load(object sender, EventArgs e) { gvwBind(); } #region 绑定GridView /// <summary> //

asp下用实现模板加载的的几种方法总结[原创]_应用技巧

1.使用adodb.stream实现的 一般虚拟主机都提供 复制代码 代码如下: function loadtempletfile(byval path)       on error resume next       dim objstream       set objstream = server.createobject("adodb.stream")       with objstream           .type = 2           .mode = 3  

asp下sql和access数据库随机取10条记录的代码newid()_应用技巧

MSSQL:select top 10 * from [table] order by newid() ACCESS:  复制代码 代码如下: '以利用rs.move嘛   '如随机取10条   n = 10   '先要判断总记录数是否少于10,若小于10,则有多少取多少 if n>10 rs.recordCount then n=rs.recordCount   dim ranNum   for i = 1 to n   Randomize()   ranNum = int(rs.record

asp下实现代码的“运行代码”“复制代码”“保存代码”功能源码_应用技巧

看到很多人需要,就放出来,好东西大家一起分享.  复制代码 代码如下: Function content_Code(Str)    dim ary_String,i,n,n_pos    ary_String=split(Str,"[ code ]")    n=ubound(ary_String)    If n<1 then     content_Code=Str     Exit function    End If    for i=1 to n     n_pos=i

asp.net编程实现删除文件夹及文件夹下文件的方法_实用技巧

本文实例讲述了asp.net编程实现删除文件夹及文件夹下文件的方法.分享给大家供大家参考,具体如下: //获取文件夹 string path = Server.MapPath("Image"); //获取文件夹中所有图片 if (Directory.GetFileSystemEntries(path).Length > 0) { //遍历文件夹中所有文件 foreach (string file in Directory.GetFiles(path)) { //文件己存在 if

Asp.net对文件夹和文件的操作类

asp.net using System;using System.IO;using System.Web; namespace SEC{    /**//// <summary>    /// 对文件和文件夹的操作类    /// </summary>    public class FileControl    {        public FileControl()        {                    }        /**//// <summa

使用ASP和ASP.NET来创建文件夹和文件。

asp.net|创建 ASP: <%sub writefile(file) Response.Write "file:"+file Dim fso, tf  Set fso = CreateObject("Scripting.FileSystemObject")  Set tf = fso.CreateTextFile(file, True)  tf.WriteLine("Testing 1, 2, 3.")  tf.WriteBlankL