'判断文件名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("<script language=javascript>alert('文件名长度不正确,按确定返回重新填写');history.back();</script>")
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("<script language=javascript>alert('文件名有非法字符,按确定返回重新填写');history.back();</script>")
response.End()
IsValidWindowsFileName=FALSE
exit Function
End If
Next
else
response.Write("<script language=javascript>alert('文件名后缀名不正确,按确定返回重新填写');history.back();</script>")
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="<font color=red>"& FileSize & "</font> KB"
ElseIf FileSize >1024 then
GetFileSize="<font color=red>"& FormatNumber(FileSize / 1024,2) & "</font> MB"
Else
GetFileSize="<font color=red>"& Size & "</font> 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