Public Declare Function GetFileSize Lib "kernel32" Alias "GetFileSize" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
解决方案 »
- 求教DoCmd.TransferText!!!
- 关闭多个数据库连接(Access)问题,在线等
- 怎么设置 MSFlexGrid1控件的列居中显示?
- 救命呀,用inner join之后,两条记录变三条记录..
- 如何让ShellExecute()具有Wait功能?
- 用VB编树结构
- 心力交翠,狂散 1000分.送源代码.
- 如何改变另一窗体的标题栏的标题!!急!!!高手请进
- html如何设置网页的背景颜色?
- 如何删除listview中的所有项(report)
- 急问!如何 创建 一个文件夹!!! 在线等待!
- 我在DATAREPORT上画了一条线。top=0,上下左右边距都是0,datareport大小为2400*2800,为什么这条线打印出来却总是在离纸的上边距0.8厘米
本示例使用 FileLen 来返回文件的字节长度。示例中假设 TESTFILE 为含有数据的文件。Dim MySize
MySize = FileLen("TESTFILE")Filelen("TESTFILE")2、LOF 函数示例
本示例使用 LOF 函数来得知已打开文件的大小。本示例假设 TESTFILE 文件内含文本数据。Dim FileLength
Open "TESTFILE" For Input As #1 ' 打开文件。
FileLength = LOF(1) ' 取得文件长度。
Close #1 ' 关闭文件。
Public Function fun_delfile(filepath As String) As Long
'判断文件大小
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
If Dir(filepath, vbNormal) <> "" Then
Set f = fs.getfile(filepath)
fun_delfile = f.Size
Set fs = Nothing End If
End Function
ByVal hFile As Long, _
lpFileSizeHigh As Long) As Long
Private Const OF_READ = &H0&
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Dim lpFSHigh As Long
Public Sub GetInfoF(FilePath As String)
Dim Pointer As Long, sizeofthefile As Long
Pointer = lOpen(FilePath, OF_READ)
'size of the file
sizeofthefile = GetFileSize(Pointer, lpFSHigh)
Label1.Caption = sizeofthefile & " bytes"
lclose Pointer
End Sub
Private Sub command1_Click()
CommonDialog1.ShowOpen
GetInfoF CommonDialog1.FileName
End Sub
Private Sub Form_Load()
With CommonDialog1
.DialogTitle = "Select a file"
.Filter = "All the files|*.*"
End With
Command1.Caption = "Select a file"
End Sub