代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><%
'建立文件夹函数
Function CreateFolder(strFolder)'参数为相对路径 '首选判断要建立的文件夹是否已经存在 Dim strTestFolder,objFSO strTestFolder = Server.Mappath(strFolder) Set objFSO = CreateObject("Scripting.FileSystemObject") '检查文件夹是否存在 If not objFSO.FolderExists(strTestFolder) Then '如果不存在则建立文件夹 objFSO.CreateFolder(strTestFolder) End If Set objFSO = Nothing
End function
'删除文件夹
Function DelFolder(strFolder)'参数为相对路径 strTestFolder = Server.Mappath(strFolder) Set objFSO = CreateObject("Scripting.FileSystemObject") '检查文件夹是否存在 If objFSO.FolderExists(strTestFolder) Then objFSO.DeleteFolder(strTestFolder) end if Set objFSO = Nothing
End function
'创建文本文件
Function Createtextfile(fileurl,filecontent)'参数为相对路径和要写入文件的内容 Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set fout = objFSO.CreateTextFile(Server.MapPath(fileurl)) fout.WriteLine filecontent fout.close Set objFSO = Nothing
End Function
'删除文件(适合所有文件)
Function Deltextfile(fileurl)'参数为相对路径 Set objFSO = CreateObject("Scripting.FileSystemObject") fileurl = Server.MapPath(fileurl) if objFSO.FileExists(fileurl) then '检查文件是否存在 objFSO.DeleteFile(fileurl) end if Set objFSO = nothing
End Function
'建立图片文件并保存图片数据流
Function Createimage(fileurl,imagecontent)'参数为相对路径和文件内容 Set objStream = Server.CreateObject("ADODB.Stream")   '建立ADODB.Stream对象,必须要ADO 2.5以上版本 objStream.Type =1   '以二进制模式打开 objStream.Open objstream.write imagecontent   '将字符串内容写入缓冲 objstream.SaveToFile server.mappath(fileurl),2   '-将缓冲的内容写入文件 objstream.Close()'关闭对象 set objstream=nothing
End Function
'远程获取文件数据
Function getHTTPPage(url)  'On Error Resume Next dim http  set http=Server.createobject("Microsoft.XMLHTTP")  Http.open "GET",url,false  Http.send()  if Http.readystate<>4 then exit function  end if  getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") set http=nothing If Err.number<>0 then  getHTTPPage = "服务器获取文件内容出错"  Err.Clear End If
End function
Function BytesToBstr(body,Cset) dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = Cset BytesToBstr = objstream.ReadText  objstream.Close set objstream = nothing
End Function
'获取图片数据流
Function getpic(url)
on error resume next
dim http
set http=server.createobject("MSXML2.XMLHTTP")'使用xmlhttp的方法来获得图片的内容
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getpic=Http.responseBody
set http=nothing
if err.number<>0 then getpic = "服务器获取文件内容出错" err.Clear
End if
End Function
'打开文件(文本形式)
Function OpenFile(fileurl)'文件相对路径 Dim Filename,fso,hndFile Filename = fileurl Filename = Server.MapPath(Filename) Set objfso = CreateObject("Scripting.FileSystemObject") If objfso.FileExists(Filename) Then set hndFile = objfso.OpenTextFile(Filename) OpenFile = hndFile.ReadAll Else OpenFile = "文件读取错误" End If Set hndFile = Nothing Set objfso = Nothing
End Function
'获得文件的后缀名
function getFileExtName(fileName)
dim pos
pos=instrrev(filename,".")
if pos>0 then
getFileExtName=mid(fileName,pos+1)
else
getFileExtName=""
end if
end function
%> Dim fso,f,folder Set fso=Server.CreateObject("scripting.filesystemobject") '改目录名 Set folder=fso.getfolder(Server.Mappath("Old")) folder.name="New" '新名字 '改文件名 Set f=fso.getfile(Server.Mappath("Old.asp")) f.name="New.asp" '新名字
'释放 <%
function copyfile(l1,l2)'复制文件  on error resume next    dim fs    set fs=createobject("Scripting.FileSystemObject")    fs.copyfile server.mappath(l1),server.mappath(l2)    set fs=nothing    if err.number<>0 then err.clear
end function
copyfile("db1.mdb","db2.mdb")
%> FSO操作全集
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.DriveExists("g:\") '判断指定硬盘驱动器是否存在
getfso=fso.GetDrive("c:") '创建自定义的FSO驱动器对象
getfso=fso.GetDriveName("c:\网络程序员伴侣") '返回文件夹的所在盘符
Set getfso=fso.Drives '创建FSO驱动器集合对象,多配合for each i in
getfso语句进行穷尽操作,支持所有[驱动器对象属性],并具有Count和Item属性Set fso=Nothing '释放fso变量与FSO组件的连接资源
</script>驱动器对象操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.GetDrive("c:").FileSystem '返回驱动器对象的文件系统类型
getfso=fso.GetDrive("c:").DriveType '返回驱动器对象的驱动器类型,返回值范围0-5
getfso=fso.GetDrive("c:").DriveLetter '返回驱动器对象的字母
getfso=fso.GetDrive("c:").IsReady '返回指定驱动器是否准备好或是否损坏
getfso=fso.GetDrive("c:").SerialNumber '返回驱动器对象的唯一十进制卷标序号
getfso=fso.GetDrive("c:").ShareName '返回驱动器对象的网络共享名
getfso=fso.GetDrive("c:").VolumeName '返回驱动器对象的卷标名,同时也可以设置其卷标名
getfso=fso.GetDrive("c:").Path '返回驱动器的实际路径,如c:\则返回c:
getfso=fso.GetDrive("c:").RootFolder '返回驱动器对象的跟文件夹
getfso=fso.GetDrive("c:").AvailableSpace'返回驱动器对象的可用容量大小
getfso=fso.GetDrive("c:").FreeSpace '返回驱动器对象的剩余空间大小
getfso=fso.GetDrive("c:").TotalSize '返回驱动器对象的总空间容量大小Set fso=Nothing '释放fso变量与FSO组件的连接资源
</script>系统文件夹操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.GetFolder("c:\") '创建自定义的FSO文件夹对象
getfso=fso.FolderExists("e:\网络程序员伴侣") '判断指定文件夹是否存在
getfso=fso.GettempName '随机返回WINDOW产生在temp文件夹中的临时文件
getfso=fso.GetparentFolderName("e:\网络程序员伴侣") '返回指定文件夹的父文件夹
fso.CreateFolder "c:\windows\新创建的文件夹路径及名称"
fso.MoveFolder "c:\windows\许移动或改名的文件夹","c:\windows\移动路径和新的文件夹名"
fso.DeleteFolder "c:\windows\要删除的目录名",false/true
fso.CopyFolder "c:\windows\须复制的目录名","c:\windows\得到付值内容的目录名",false/true
Set getfso=fso.Folders '创建FSO文件夹集合对象,多配合for each i in getfso语句进行穷尽操作,支持所有[文件夹对象属性],并具有Count和Item属性,具有AddFolders方法
Set getfso=fso.Files '创建FSO文件夹内文件集合对象,多配合for each i in getfso语句进行穷尽操作,支持所有[文件对象属性],并具有Count和Item属性
Set fso=Nothing '释放fso变量与FSO组件的连接资源</script>文件夹对象操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.GetFolder("c:\windows").Name '返回文件夹的名字,这里返回WINDOW
getfso=fso.GetFolder("c:\windows").ShortName '返回文件夹[8.3]格式的名称
getfso=fso.GetFolder("c:\windows").Attributes '返回文件夹的属性,可返回0,1,2,4,8,16,32,64,128
getfso=fso.GetFolder("c:\windows").Size '返回文件夹(包括子文件夹)内文件占用空间大小
getfso=fso.GetFolder("c:\windows").Type '返回文件夹类型信息
getfso=fso.GetFolder("c:\windows").Path '返回文件夹的真实路径
getfso=fso.GetFolder("c:\windows").ShortPath '返回文件夹[8.3]格式的路径
getfso=fso.GetFolder("c:\windows").Drive '返回文件夹所在驱动器
getfso=fso.GetFolder("c:\windows").Files.count '返回文件夹包含的所有文件对象集合
getfso=fso.GetFolder("c:\windows").SubFolders.count '返回文件夹包含的所有子文件夹的对象集合
getfso=fso.GetFolder("c:\windows").ParentFolder '返回文件夹的父文件夹对象
getfso=fso.GetFolder("c:\windows").IsRootFolder '返回文件夹是否为跟文件夹,是返回true否返回false
getfso=fso.GetFolder("c:\windows").DateCreated '返回文件夹的最初创建时间
getfso=fso.GetFolder("c:\windows").DateLastAccessed '返回文件夹最后一次访问时间
getfso=fso.GetFolder("c:\windows").DateLastModified '返回文件夹最近修改的时间
fso.GetFolder("c:\windows").CreateTextFile "新建的文件名及后缀",true/false,true/false
fso.GetFolder("c:\windows\要删除的目录名").Delete true
fso.GetFolder("c:\windows\要移动改名的目录名").Move "文件夹将要移动到的路径及自定义文件夹名称"
fso.GetFolder("c:\windows\旧目录").Copy "复制到路径",true/false '在指定路径付值此文件夹,true=覆盖,false相反
Set fso=Nothing '释放fso变量与FSO组件的连接资源</script>系统文件操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.GetFile("c:\windows\help.html") '得到文件完整路径
getfso=fso.GetFileName("c:\windows\help.html") '得到文件名称和后缀
getfso=fso.GetExtensionName("c:\windows\help.html") '得到文件的文件类型(后缀),不含小数点
getfso=fso.FileExists("c:\windows\文件名.html") '判断文件是否存在
fso.MoveFile "要移动及改名的原文件路径","移动到某路径及自定义新文件名"
fso.DeleteFile "c:\windows\要删除的文件所在路径",false/true
fso.CopyFile "c:\windows\须复制的旧文件.txt","c:\windows\复制后的文件名.jpg",false/true
fso.OpenTextFile "c:\windows\desktop\要打开操作的文件名称.txt",1/2/8,true/false,0/-1/-2 'ForReading=1=只读方式,ForWriting=2=可写方式,ForAppending=8=追加方式.true=如果打开的文件不存在则创建该文件.TristateFalse=0=以系统默认方式打开,TristateTrue=-1=以Unicode格式打开文件,TristateUseDefaule=-2=以ASCLL格式打开文件(缺剩值)
fso.CreateTextFile "c:\windows\desktop\新建的文件名称.txt",false/true,false/true '前者true覆盖以存在同名文件,后者为true新文件将以Unicode方式创建,反之=结果相反
Set fso=Nothing '释放fso变量与FSO组件的连接资源
</script>文件对象操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
getfso=fso.GetFile("c:\windows\笔记本.txt").Name '返回文件对象的名称包含后缀
getfso=fso.GetFile("c:\windows\笔记本.txt").ShortName '返回文件对象的[8.3]名称包含后缀
getfso=fso.GetFile("c:\windows\笔记本.txt").Attributes '返回文件对象的属性,可返回0,1,2,4,8,16,32,64,128
getfso=fso.GetFile("c:\windows\笔记本.txt").Size '返回文件对象的大小
getfso=fso.GetFile("c:\windows\笔记本.txt").Type '返回文件对象的类型
getfso=fso.GetFile("c:\windows\笔记本.txt").Path '返回文件对象的完整路径
getfso=fso.GetFile("c:\windows\笔记本.txt").ShortPath '返回文件对象的[8.3]的完整路径
getfso=fso.GetFile("c:\windows\笔记本.txt").Drive '返回此文件对象所在的驱动器
getfso=fso.GetFile("c:\windows\笔记本.txt").ParentFolder '返回文件对象所在的文件夹
getfso=fso.GetFile("c:\windows\笔记本.txt").DateCreated '返回文件对象的创建日期
getfso=fso.GetFile("c:\windows\笔记本.txt").DateLastAccessed '返回文件对象的最后访问日期
getfso=fso.GetFile("c:\windows\笔记本.txt").DateLastModified '返回文件对象的最后修改时间
fso.GetFile("c:\windows\笔记本.txt").Copy "复制到的路径和文件名",true/false
fso.GetFile("c:\windows\笔记本.txt").Delete true
fso.GetFile("c:\windows\笔记本.txt").Move "移动到的路径及自定义文件名
Set fso=Nothing '释放fso变量与FSO组件的连接资源
</script>文件对象读写操作
<script language=vbs>
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject") '使FSO组件可以被fso变量调用
set link1=fso.GetFile("c:\windows\笔记本.txt").OpenAsTextStream(1/2/8,0/-1/-2)
open1=link1.AtendOfline '判断文件指针是否以在行的末尾
open2=link1.AtendOfstream '判断文件指针是否一再文件的末尾
open3=link1.Column '返回当前字符所在文件的列号
open4=link1.Line '返回当前字符所在文件的行号
open5=link1.Read(10) '读取文件中指定数量的字符
open6=link1.ReadAll '读取文件中所有的字符
open7=link1.ReadLine '读取文件中一行中含有的字符
open8=link1.Write "字符串" '将自定字符串或字符串变量写入文件
open9=link1.WriteLine "字符" '将自定字符+一个换行符写入文件
open10=link1.WriteBlankLines 10 '将指定数量的换行符写入文件
open11=link1.Skip 10 '使文件指针跳过指定数量的字符
open12=link1.SkipLine '使文件指针跳到下一行
link1.Close '文件操作完毕,销毁文件对象指针
Set fso=Nothing '释放fso变量与FSO组件的连接资源
</script>

ASP FSO文件处理函数大全相关推荐

  1. C语言文件操作函数大全(看到总结的真的很好,就转载贡献给大家了)

    C语言文件操作函数大全 clearerr(清除文件流的错误旗标) 相关函数 feof 表头文件 #include<stdio.h> 定义函数 void clearerr(FILE * st ...

  2. c语言全文件操作函数,C语言文件操作函数大全

    C语言 文件操作函数大全 C语言文件操作函数 2007-10-17 19:21 13.1C语言文件 1,两种文件存取方式(输入,输出方式) 顺序存取 直接存取 2,数据的两种存放形式 文本文件 二进制 ...

  3. C语言文件操作函数大全

    unix中一切皆文件,所以文件操作至关重要! clearerr(清除文件流的错误旗标) 相关函数 feof 表头文件 #include<stdio.h> 定义函数 void clearer ...

  4. asp系统转换php系统时间函数,ASP_ASP中的时间函数大全 时间操作函数,Date 函数 描述:返回当前系统日 - phpStudy...

    ASP中的时间函数大全 时间操作函数 Date 函数 描述:返回当前系统日期. 语法:Date DateAdd 函数 描述:返回已添加指定时间间隔的日期. 语法:DateAdd(interval, n ...

  5. Asp中一些FSO方面的函数

    最近在攻asp.net,没空写东西,吧asp中一些fso方面的函数整理了一些,申请落伍. '//==================================文件操作============== ...

  6. ASP系列VB函数大全

    ASP系列VB函数大全 ASP函数大全 ASP函数与VBSCRIPT类似,以下举一些常用的函数 Array() 函数返回一个数组 表达式 Array(list) 允许数据类型: 字符,数字均可 实例: ...

  7. Asp.Net文件和文件夹操作大全

    /// <summary>         /// 创建文件夹         /// </summary>         /// <param name=" ...

  8. [ASP] asp日期函数大全(转)

    1. Now 传回系统的日期及时间. 例:Now 传回值:2002/11/2 10:23:30 AM 2. Date 传回系统的日期. 例:Date 传回值:2002/11/2 3. Time 传回系 ...

  9. oracle中各种函数,oracle中常用函数大全

    1.数值型常用函数 函数 返回值 样例 显示 ceil(n) 大于或等于数值n的最小整数 select ceil(10.6) from dual; 11 floor(n) 小于等于数值n的最大整数 s ...

最新文章

  1. 一种解决启动进程传递参数过长的方法
  2. 大数据驱动的运营创新和探索
  3. php padright,[扩展推荐] PHP 字符串操作类 Twine
  4. LeetCode-剑指 Offer 25. 合并两个排序的链表
  5. Mycat社区出版: 分布式数据库架构及企业实践——基于Mycat中间件
  6. html的混合标记,HTML XPath:提取与多个标签混合的文本?
  7. Golang的CSP很酷?其实.NET也可以轻松完成
  8. java url下载ics_使用Microsoft Graph API处理外部(Internet / .ics)日历URL
  9. 【MySQL】基于Docker的Mysql主从复制搭建
  10. mysql查询数据库第一条记录_SQL获取第一条记录的方法(sqlserver、oracle、mysql数据库)...
  11. esxi挂载Linux的nfs盘,ESXi安装centos7挂载群晖NFS
  12. Spring Boot笔记-validation的使用及统一异常处理
  13. C语言随笔小算法:单项链表如何实现队列
  14. JS代码对表格进行新增时无法解析HTML代码的解决方式
  15. java 万年历_改进java万年历,前几天看到别人写的java万年历,其中不足之处多多...
  16. OSx86的来龙去脉
  17. Linux学习-软件磁盘阵列
  18. 008 [转载]文件后缀查询
  19. 深入了解Spring IoC
  20. android 8 刷机教程视频教程,教你Android 8.0的刷机教程

热门文章

  1. POJ1753 filp game
  2. 如何使用OpenCV内置的stitcher类来拼接图片?
  3. 笔记----DX11.0转为DX11.2
  4. 【嘉立创过孔大小】嘉立创打板子最小孔径和线距要求是多少
  5. abb机器人易耗品_ABB机器人中文手册
  6. 项目思路---接口的权限控制、登陆校验以及白名单的设置
  7. 这多年来我一直在钻研的技术
  8. PLC控制与继电器控制有什么区别
  9. 【朝花夕拾系列一】信号与系统(奥本海姆)第一章
  10. Reasoning about Quantities in Natural Language