PDA

View Full Version : How to detect Disk Size (WXP)



angie
01-10-2003, 11:13 AM
Hello, all:
I'm writing a program using WSH and VBScript to backup files from hardisk to DVD disk. My program needs to detect if the DVD disk is full, then pop a message to the user. I don't know how to dicide the disk size in WSH and VBScript, any suggestions will be greatly appreciated. Thanks.

<P ID="edit"><FONT class="small">Edited by angie on 01/10/03 11:15.</FONT></P>

Jama
01-10-2003, 02:43 PM
Set fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.GetDrive("c:")
s = Drv.FreeSpace & " bytes" & vbNewline
s = s & Drv.FreeSpace / 1024 & " Kb" & vbNewline
s = s & Round(Drv.FreeSpace / 1048576, 0) & " MB"
wscript.echo s
Set Drv = Nothing

Jama

angie
01-10-2003, 03:27 PM
Thanks, Jama.
Do you know how to detect the size of a file?

Jama
01-10-2003, 09:42 PM
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFile = FSO.GetFile("C:\TestFolder\New Text Document.txt")

s = "Name: " & MyFile.Name & vbNewline
s = s & "Size: " & MyFile.Size & " Bytes"
wscript.echo s

Set FSO = Nothing
Set MyFile = Nothing

<a target="_blank" href=http://www.devguru.com/Technologies/vbscript/quickref/file.html>http://www.devguru.com/Technologies/vbscript/quickref/file.html</a>


Jama

angie
01-13-2003, 04:32 PM
Thanks!