New topic: free disk space??
<http://forums.realsoftware.com/viewtopic.php?t=47642> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message RicSum Post subject: free disk space??Posted: Thu Apr 18, 2013 10:49 pm Joined: Fri Jun 05, 2009 4:54 pm Posts: 454 Location: London, England Hi, If I create a small portable app (windows) which is run from a usb stick, is it possible to determine how much free space is left on the usb stick. The app loads in database files (also on the same stick), therefore, I need to ensure that as the database files grow, there is still space on the stick. Hope that made sense. Thanks. _________________ RealStudio Professional Edition 2012 r2 Developing on OS X 10.8 (Mountain Lion) Deploying on Windows XP / 7 / 8 Top charonn0 Post subject: Re: free disk space??Posted: Fri Apr 19, 2013 1:17 am Joined: Mon Apr 02, 2007 2:08 am Posts: 1191 Location: San Francisco, CA, USA You can use the GetDiskFreeSpaceEx API function: Declare Function GetDiskFreeSpaceExW Lib "Kernel32" (dirname As WString, ByRef freeBytesAvailable As UInt64, _ ByRef totalbytes As UInt64, ByRef totalFreeBytes As UInt64) As Integer Dim userfree, totalsize, totalfree As UInt64 Call GetDiskFreeSpaceExW(App.ExecutableFile.Parent.AbsolutePath, userfree, totalsize, totalfree) The totalfree value represents the total available free space, the userfree value represents the free space available to the current user (which is usually the same.) You can pass the absolute path to any directory in the drive in question, so App.ExecutableFile.Parent will work fine. _________________ Boredom Software Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
