473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disk space exception ?

Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstat e() returns badbit.

Jul 23 '05 #1
2 3212
Sagar Choudhary wrote:
Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstat e() returns badbit.


IIRC, that's a platform specific thing that you'll want to look into the
platform documentation for. I'm not aware of any standard C++ way of
finding how much space is free (apart from the ostream being writable
and it... not being writable or, as you pointed out, returning an error).

For example, the Microsoft Windows PlatformSDK offers:

BOOL GetDiskFreeSpac e(
LPCTSTR lpRootPathName,
LPDWORD lpSectorsPerClu ster,
LPDWORD lpBytesPerSecto r,
LPDWORD lpNumberOfFreeC lusters,
LPDWORD lpTotalNumberOf Clusters
);

(include windows.h)

http://msdn.microsoft.com/library/de...kfreespace.asp


--
Peter MacMillan
e-mail/msn: pe***@writeopen .com
icq: 1-874-927

GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$
N o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r--
y(--)
Jul 23 '05 #2
Sagar Choudhary wrote:
Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstat e() returns badbit.

Wrong, or let us clarify. The rdstate() method returns
badbit when there is problem writing to the stream. We
don't have a clue as to which problem(s) are associated
with the "badbit". For example, one could not distinguish
faulty media, missing media or full media by using the
"badbit". All we know is that there was an error. The
details are up to the implementation or the platform.

As for availability of disk space, the best course of
action is to use some platform specific functions since
C++ has no support for this.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Jul 23 '05 #3

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

Similar topics

3
6293
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When I installed Sharepoint Services I got the error and had to reboot and then everything was fine. I get it sometime when running aspx pages. It's...
12
10994
by: New World Order Pigs | last post by:
Is there no way in .net to get disk space remaining for a given drive??? I can't believe it and yet is seems to be so. If someone knows of a way to do this in the .net libraries I'd be very much appreciative. Thanks, LT.
5
7492
by: Karl | last post by:
Hi, I have some code that will save the contents of a Rich Text Box in either a Text or Rich Text Format file. The code is using the SaveFileDialog and is working correctly. I have been testing the code and added in some exception handling to cater for any problems. During testing I have found that if I attempt to save to a floppy disc...
1
5891
by: Peter | last post by:
Hi, I am getting really weird error, when I try to load one of my ASP.NET website pages: Server Error in '/' Application. ----------------------------------------------------------- --------------------- There is not enough space on the disk.
0
2480
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When I installed Sharepoint Services I got the error and had to reboot and then everything was fine. I get it sometime when running aspx pages. It's...
1
3701
by: simon | last post by:
I have encountered this error message, do anyone know what is happening?? Thanks. Description: An unhandled exception occurred during compilation using the CodeDomProvider 'Microsoft.CSharp.CSharpCodeProvider'. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
2
3319
by: Dan | last post by:
I've written a short function to return the amount of free disk space on a specified drive (for example c:) and it works fine on my development platform. In production, however, I am getting an exception that I can't figure out. Any help would be appreciated. Here's my code: Public Function GetFreeSpace(ByVal strDiskDrive As String)...
2
16060
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. I have 35 Gigs of disk space free. It doesn't happen all the time but it does happen. When I installed Sharepoint Services I got the error and had to reboot and then everything was fine. I get it...
6
23982
by: Christine | last post by:
erver Error in '/test' Application. -------------------------------------------------------------------------------- There is not enough space on the disk. Description: An unhandled exception occurred during compilation using the CodeDomProvider 'Microsoft.VisualBasic.VBCodeProvider'. Please review the stack trace for more information about...
0
7896
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7827
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8328
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.