I want to know if I can copy the files in filelistbox1 to the target defined in Dir2.path, how can I measure if the target drive has enough hard disk space to store those files ?
Oostwijk I see that you have not voted ANY of your replies as helpfull. To get the most from this site, Please read FAQ222-2244 (Item 15).
Free Space on selected drive..
Option Explicit
'API Declarations
Private Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
'Call this function to get the Amount of Free Disk Space (in Bytes)
'Pass to this function only the letter of the drive
Function FreeDiskSpace(DriveLetter As String)
Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim FreeClusters As Long
Dim NumberOfClusters As Long
Dim ret As Long
ret = GetDiskFreeSpace(DriveLetter & ":\", SectorsPerCluster, BytesPerSector, FreeClusters, NumberOfClusters)
FreeDiskSpace = BytesPerSector * SectorsPerCluster * FreeClusters
End Function
Private Sub Command1_Click()
MsgBox FreeDiskSpace("C" \ 1024 & " Kb Free Space in Drive C"
End Sub
This is one way to copy files from one dir to another..
Public Function CopyDir(Source As String, Dest As String, OverWrite As Boolean)
'This function uses the Windows Scripting Host
'You must have the scripting engine installed to use this code.
Dim fso
'Create file system object
Set fso = CreateObject("Scripting.FileSystemObject"
'put windows scripting host to work
fso.CopyFolder Source, Dest, OverWrite
End
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.