VB程序员博客

VB程序开发

'函数作用:取得文件后缀名
'*******************************************
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>&nbsp;KB"
ElseIf FileSize >1024 then
  GetFileSize=" <font color=red>"& FormatNumber(FileSize / 1024,2) & " </font>&nbsp;MB"
Else
  GetFileSize=" <font color=red>"& Size & " </font>&nbsp;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

该文章转载自网络大本营:http://www.xrss.cn/Info/12525.Html

jf………….

如果文件没有后缀名咋办?

以后需再关注,现在先帮你顶一下

有点难度哦


标签: , , ,