VB保存文件问题

来源:百度知道 编辑:UC知道 时间:2024/05/08 06:49:33
将*.jpg保存到E:\A\下,如果E:\空间快满
的时候就关闭窗体

*.JPG文件保存的问题很简单,在此略。
此问题关键是:在保存文件之前先判断E盘的已用空间和总空间。如果已用空间+即将复制的JPG文件长度>总空间,则关闭窗体。
------------------------------------------
下面给出判断磁盘空间的有关源码,供参考。
------------------------------------------
'From1内加入Drive1,Label1,Label2
和command1
'然后复制下面代码,运行即可
Option Explicit
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long

Private Sub Command1_Click()
End
End Sub

Private Sub Drive1_Change()
Dim Sectors As Long, Bytes As Long, Free As Long, Total As Long
Dim FreeKB As Long, TotalKB As Long

GetDiskFreeSpace Left(Drive1.Drive, 2) & "\", Sectors, Bytes, Free, Total
FreeKB = Bytes * Sectors * (Free \ 1024)
TotalKB = Bytes * Sectors * (Tota