Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4958253
  • 博文数量: 1696
  • 博客积分: 10870
  • 博客等级: 上将
  • 技术积分: 18357
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 15:16
文章分类
文章存档

2017年(1)

2016年(1)

2015年(1)

2013年(1)

2012年(43)

2011年(17)

2010年(828)

2009年(568)

2008年(185)

2007年(51)

分类: WINDOWS

2007-10-22 17:07:06

'判断文件名windows下的目录名是否合法
Function IsValidWindowsFolderName(strFolderName)
IsValidWindowsFolderName=TRUE
sErrorStr=Array("/","\",":","*","?","""","<",">","|")
iNameLength=Len(strFolderName)
'判断目录长度是否合法
If iNameLength<1 or iNameLength=null or iNameLength>255 Then
IsValidWindowsFolderName=FALSE
Else
'判断目录名字中是否有非法字符
 For i=0 To 8
 If instr(strFolderName,sErrorStr(i)) Then
 IsValidWindowsFolderName=FALSE
 exit Function
 End If
 Next
End If
End Function

编程大本营

'判断文件名windows下的文件名是否合法
Function IsValidWindowsFileName(strFileName)
IsValidWindowsFileName=TRUE
sErrorStr=Array("/","\",":","*","?","""","<",">","|")
iNameLength=Len(strFileName)
If iNameLength<1 or iNameLength=null or iNameLength>255 Then
 response.Write("")
 response.End()
IsValidWindowsFileName=FALSE
Else
if instr(strFileName,".htm")>0 or instr(strFileName,".html")>0 or instr(strFileName,".asp")>0 or instr(strFileName,".shtml")>0 then
 For i=0 To 8
 If instr(strFileName,sErrorStr(i)) Then
 response.Write("")

不能采集本站


 response.End()
 IsValidWindowsFileName=FALSE
 exit Function
 End If
 Next
else
 response.Write("")
 response.End()
IsValidWindowsFileName=FALSE
end if
End If
End Function
 
'*******************************************
'函数作用:取得文件路径
'*******************************************
Function GetLocalPathDir(ByVal D)
 If Len(D) = 0 then Exit Function
 if instr(strFileName,"\")<0 then
 GetLocalPathDir=D
 else
 GetLocalPathDir=Left(D,InStrRev(D,"\")-1)
 end if
End Function
'*******************************************
'函数作用:取得文件名
'*******************************************
Function GetLocalPathFile(ByVal D)
 If Len(D) = 0 then Exit Function 不能采集本站
 if instr(strFileName,"\")<0 then
 GetLocalPathFile=D
 else
 GetLocalPathFile=Right(D,Len(D)-InStrRev(D,"\"))
 end if
End Function
'*******************************************
'函数作用:取得文件后缀名
'*******************************************
Function GetLocalPathFileExt(ByVal D)
 If Len(D) = 0 then Exit Function
 if instr(strFileName,".")<0 then  Exit Function
 GetLocalPathFileExt=Right(D,Len(D)-InStrRev(D,"."))
End Function
编程大本营

'*******************************************
'函数作用:取得文件的后缀名
'*******************************************
Function GetExtensionName(name)
 Dim ArrayFileName
 ArrayFileName=Split(name,".")
 GetExtensionName=ArrayFileName(Ubound(ArrayFileName))
End Function

防采集

'*******************************************
'函数作用:格式化文件的大小
'*******************************************
Function GetFileSize(size)
 Dim FileSize
 FileSize=size / 1024
 FileSize=FormatNumber(FileSize,2)
 If FileSize < 1024 and FileSize > 1 then
  GetFileSize=""& FileSize & " KB"
 ElseIf FileSize >1024 then
  GetFileSize=""& FormatNumber(FileSize / 1024,2) & " MB"
 Else
  GetFileSize=""& Size & " Bytes"
 End If
End Function
'*******************************************
'函数作用:格式化文件属性
'*******************************************
Function GetFileAttr(AttributesNo)
 Dim AttributesName
 Select Case AttributesNo

编程大本营


 Case 0
 AttributesName="Normal"
 Case 1
 AttributesName="ReadOnly"
 Case 2
 AttributesName="Hidden"
 Case 4
 AttributesName="System"
 Case 8
 AttributesName="Volume"
 Case 16
 AttributesName="Directory"
 Case 32
 AttributesName="Archive"
 Case 64
 AttributesName="Alias"
 Case 128
 AttributesName="Compressed"
 Case else
 AttributesName=AttributesNo
 end Select
 GetFileAttr=AttributesName
 'Normal              0        一般文件,未设置属性
    'ReadOnly            1        只读文件,属性为读/写 防采集
    'Hidden              2        隐藏文件,属性为读/写
    'System              4        系统文件,属性为读/写
    'Volume              8        磁盘驱动器卷标,属性为只读
    'Directory           16       文件夹或目录,属性为只读
    'Archive             32       自上次备份后已经改变的文件,属性为读/写
    'Alias               64       链接或快捷方式,属性为只读

编程大本营


    'Compressed          128      压缩文件,属性为只读
 
End Function
阅读(4312) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~