Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find disk size (97 SR2)

    Is there a function, or an API call, that will tell me the capacity of a disk? In code, I want to compare .mdb file size to a zip disk capacity before attempting to copy the file to the zip drive.
    Thanks, Jon

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find disk size (97 SR2)

    If you have Internet Explorer 4 or later, you can use scripting. In any module, set a reference to Windows Scripting Runtime (SCRRUN.DLL in your system folder), or to the Windows Script Host (WSHOM.OCX in your system folder)

    The following code will show the size and free space on a drive:

    Dim fso As New Scripting.FileSystemObject
    Dim dr As Scripting.Drive
    Set drv = fso.GetDrive("C:")
    MsgBox drv.FreeSpace & " bytes free of total " & drv.TotalSize & "bytes"
    Set drv = Nothing
    Set fso = Nothing

    To get the size in kilobytes, divide FreeSize or TotalSize by 1024; for the size in megabytes, divide by (1024*1024).

  3. #3
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find disk size (97 SR2)

    Thanks Hans. Also, I found the Windows API call GetDiskFreeSpaceEx that looks like it would work (I haven't tried yet). I think I like your idea better, anyway.
    Thanks again,
    Jon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •