473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

a2k - find out diskspace remaining

Given a drive letter is there some cut and paste code out there that will
check the space remaining?
I want to be able to warn the user if the backup operation might not succeed
due to a lack of diskspace.

Haven't been able to track down what I need hence the post.

thanks
Martin
Nov 13 '05 #1
5 3227
On Sat, 2 Oct 2004 20:25:23 +0100, "Deano" <ma**********@gmail.com>
wrote:
Given a drive letter is there some cut and paste code out there that will
check the space remaining?
I want to be able to warn the user if the backup operation might not succeed
due to a lack of diskspace.

Haven't been able to track down what I need hence the post.

thanks
Martin

Hi
Here's an amusing way of doing it. The free space can exceed long.
Set refs to include Microsoft Scripting Runtime

Function testit()
Dim FreeString As String
MsgBox "Free space on C is " & GetFreeSpace("C")
End Function

Private Function GetFreeSpace(ByVal strDriveLetter As String) As
Currency
Dim fso As Scripting.FileSystemObject
Dim dr As Scripting.Drive

Set fso = New Scripting.FileSystemObject
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing

End Function

Incidentally I found this out by typing "disk free space vba" into
Google and looking at the first reference returned. I did change it to
use the currenct type however!

David

Nov 13 '05 #2
David Schofield wrote:
On Sat, 2 Oct 2004 20:25:23 +0100, "Deano" <ma**********@gmail.com>
wrote:
Given a drive letter is there some cut and paste code out there that
will check the space remaining?
I want to be able to warn the user if the backup operation might not
succeed due to a lack of diskspace.

Haven't been able to track down what I need hence the post.

thanks
Martin

Hi
Here's an amusing way of doing it. The free space can exceed long.
Set refs to include Microsoft Scripting Runtime

Function testit()
Dim FreeString As String
MsgBox "Free space on C is " & GetFreeSpace("C")
End Function

Private Function GetFreeSpace(ByVal strDriveLetter As String) As
Currency
Dim fso As Scripting.FileSystemObject
Dim dr As Scripting.Drive

Set fso = New Scripting.FileSystemObject
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing

End Function


Cool, though it would be nice to have something that didn't require a
reference.

Incidentally I found this out by typing "disk free space vba" into
Google and looking at the first reference returned. I did change it to
use the currenct type however!


Roll on the semantic web I say.
Nov 13 '05 #3
On Sat, 2 Oct 2004 21:59:05 +0100, "Deano" <ma**********@gmail.com>
wrote:
David Schofield wrote:
On Sat, 2 Oct 2004 20:25:23 +0100, "Deano" <ma**********@gmail.com>
wrote:
Given a drive letter is there some cut and paste code out there that
will check the space remaining?
I want to be able to warn the user if the backup operation might not
succeed due to a lack of diskspace.

Haven't been able to track down what I need hence the post.

thanks
Martin

Hi
Here's an amusing way of doing it. The free space can exceed long.
Set refs to include Microsoft Scripting Runtime

Function testit()
Dim FreeString As String
MsgBox "Free space on C is " & GetFreeSpace("C")
End Function

Private Function GetFreeSpace(ByVal strDriveLetter As String) As
Currency
Dim fso As Scripting.FileSystemObject
Dim dr As Scripting.Drive

Set fso = New Scripting.FileSystemObject
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing

End Function


Cool, though it would be nice to have something that didn't require a
reference.

Incidentally I found this out by typing "disk free space vba" into
Google and looking at the first reference returned. I did change it to
use the currenct type however!


Roll on the semantic web I say.

Hi
Well you can use the api GetDiskFreeSpaceEx

David

Nov 13 '05 #4
....
Search google on "GetDiskFreeSpaceEx vba"
Pick first reply
I already sent this but I think i emailed it by mistake
David
Nov 13 '05 #5
"Deano" <ma**********@gmail.com> wrote in message
news:41***********************@ptn-nntp-reader02.plus.net...
David Schofield wrote:
On Sat, 2 Oct 2004 20:25:23 +0100, "Deano" <ma**********@gmail.com>
wrote:
Given a drive letter is there some cut and paste code out there that
will check the space remaining?
I want to be able to warn the user if the backup operation might not
succeed due to a lack of diskspace.

Haven't been able to track down what I need hence the post.

thanks
Martin

Hi
Here's an amusing way of doing it. The free space can exceed long.
Set refs to include Microsoft Scripting Runtime

Function testit()
Dim FreeString As String
MsgBox "Free space on C is " & GetFreeSpace("C")
End Function

Private Function GetFreeSpace(ByVal strDriveLetter As String) As
Currency
Dim fso As Scripting.FileSystemObject
Dim dr As Scripting.Drive

Set fso = New Scripting.FileSystemObject
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing

End Function


Cool, though it would be nice to have something that didn't require a
reference.


If you want to avoid having to set a reference, but still use that same
code, you can always use Late Binding:

Private Function GetFreeSpace(ByVal strDriveLetter As String) As Currency
Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing

End Function
It is possible, I suppose, that some shops may have disabled FSO though, due
to security concerns.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Greg Baker | last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to post code and ask for help? I hope so.. :) Here's my problem: I am trying problem 127 of the valladolid online...
2
by: coeng | last post by:
I've run into a little problem with an OO design. Suppose I have a class called "Message". Each time I receive a communication from an external source, I instantiate an object of class...
11
by: mailar | last post by:
Hi, I am using DB2 version 8.2 on Windows XP platform. I have a table 'EMP' with one field named 'NAME' of type CHAR , size 80. Also , I have a record with NAME='john' Now, when I try to...
18
by: junky_fellow | last post by:
What is the proper way of finding an end of file condition while reading a file ? How does feof() detects that end of file is reached ? Does this require support from OS ? Thanx in advance...
4
by: Ed L. | last post by:
I am trying to identify tables with significant diskspace "leakage" due to in appropriately low max_fsm_pages settings. I can see the results of VACUUM ANALYZE VERBOSE output counts of tuples and...
8
by: vasu1308 | last post by:
Hi I want to monitor disk space and send a email if it exceeds the limit. I m using "use Filesys:: Diskspace" but there is an error in compling. "Can't locate Filesys/Diskspace.pm in @INC...
2
by: Konstantinos Pachopoulos | last post by:
Hi, i have the following string s and the following code, which doesn't successfully remove the "\", but sucessfully removes the "\\". .... if i!="\\": .... newS=newS+i .......
3
by: joshfbm | last post by:
In the title are the two errors I get when compiling. The code is as follows int main() { int runs; double high=0; double remaining=0; double fremaining=0;
1
maxx233
by: maxx233 | last post by:
I need to figure out a way to generate a report to find customers in our DB that have unused credits on their account so we can void them out periodically - we manually assign them credits, they make...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.