我也公用一下:我的新闻系统的文件处理函数集:

<%
'##########################
'文件处理函数集
'张胜永windxixi编制
'使用此函数集非常方便
'
'
'
'#########################
'########################
Function CreatePath(sPath)
'生成指定目录结构
'########################
 Dim fso
 Dim pos
 Dim aTmp
 Dim sNewpath
 Dim n
 Set fso=Server.CreateObject("Scripting.FileSystemObject")
 pos=Instr(3,sPath,"/",1)
 aTmp=Split(Mid(sPath,pos+1),"/")
 sNewPath=Left(sPath,pos-1)
 For n = 0 to Ubound(aTmp)
  sNewPath = sNewPath & "/" & aTmp(n)
  If NOT fso.FolderExists(sNewPath) then fso.CreateFolder(sNewPath)
 Next
 CreatePath=(Err=0)
End Function
'############################
Sub WriteFile(Filstr,Filename)
'写入文件
'############################
 Dim File,FSO
 Set FSO=Server.CreateObject("Scripting.FileSystemObject")
 Set File=FSO.CreateTextFile(Filename,True)
 File.WriteLine(Filstr)
 File.Close
 Set FSO=nothing
End Sub

'############################################
Function MakeFile(Filstr,Filename)
'make txt files over on 03.03.09 6:10PM
'建立目录并写入内容
'############################################
    dim filenamet
    filenamet=left(filename,instrRev(filename,"/"))
 createpath(filenamet)
 WriteFile Filstr,Filename
End Function
'################################################
Function Del(f)
'Kill the Folder or File over on 03/03/09 6:29PM
'################################################
 dim FSO,i,tArr
    Set FSO=Server.CreateObject("Scripting.FileSystemObject")
 tArr=Split(f,", ")
 For i=0 to Ubound(tArr)
  tArr(i)=Replace(tArr(i),"`",",")
  
  If Right(tArr(i),1)="/" Then ' Dir
    tArr(i)=Left(tArr(i),Len(tArr(i))-1) ' Remove trailing "/"
    fso.deleteFolder tArr(i), true
  Else 'file
   fso.deleteFile tArr(i),true
  End If
 Next
End Function
'###########################################################################################
function makefilename()
'make a name of files it is use the news format.if a news add the name is enter
'##########################################################################################
  fname = now()
  fname = replace(fname,"-","")
  fname = replace(fname," ","")
  fname = replace(fname,":","")
  fname = replace(fname,"PM","")
  fname = replace(fname,"AM","")
  fname = replace(fname,"上午","")
  fname = replace(fname,"下午","")
  makefilename=fname&".htm"
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

%>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值