Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

diskspace

Status
Not open for further replies.

channelmaster

Technical User
Dec 9, 2001
52
PH
How can you check if the disk has sufficient free space for back up purposes. Thanks again.
 
Could use aDir() and FSIZE to estimate space requirements and DiskSpace() to measure space availability. Check VFP Help system for proper usage of functions.

Jean
 
As Jean was saying....try something like this...

nspaceleft = Diskspace()
nfiles = Adir(arfn)
nspaceneeded = 0
For ncount = 1 To nfiles
nspaceneeded = nspaceneeded + arfn(ncount,2)
Endfor
If nspaceleft <= nspaceneeded
Messagebox(&quot;There is not enough room on your hard drive.&quot;,16,&quot;Unable Backup...&quot;)
Else
*!* Do your backup code
Endif

Slighthaze = NULL
 
the arfn is an array that will hold the information returned from the Adir function. From the help file:

ADIR(ArrayName [, cFileSkeleton [, cAttribute [, nFlag]]])

if the array doesn't exist then VFP creates it for you Slighthaze = NULL
 
Ok i got it,in my case i have a slave drive on drive d: and i want to know if there is a sufficient diskspace on drive d: before i back up my files, how can i compare my files in,e.g. c:\mydata\ to d:\mybackup\.thanks again
 
Try this:

nDBFfiles = ADIR(aDBFfiles, 'c:\mydata\*.dbf')
nCDXfiles = ADIR(aCDXfiles, 'c:\mydata\*.cdx')
nDSpace = DISKSPACE('D:')

STORE 0 TO nCspace
FOR i = 1 TO nDBFfiles
nCspace = nCspace + aDBFfiles[i, 2]
NEXT
FOR i = 1 TO nCDXfiles
nCspace = nCspace + aCDXfiles[i, 2]
NEXT

IF nDspace < nCspace
MESSAGEBOX('Not enough room')
ELSE
MESSAGEBOX('Plenty of room')
ENDIF
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top