From: Syed Khadeer on
Hello,
I am facing problem with usage of CStdioFile::WriteString method.
The problem is as follows:

There is only 4 to 8 KB of disk space left in the target directory.
I have a CString variable containing about 12KB of data.
I open a ASCII file using CStdioFile as follows:

CFileException exception;
CStdioFile outputFile;
if (!outputFile.Open(m_strFilePath, CFile::modeCreate |
CFile::modeWrite | CFile::shareExclusive | CFile::typeText))
{
// handle error here
}

then attempt to write to the file as follows:
try
{
outputFile.WriteString(strValue);
}
catch (CFileException* fileException)
{
// handle error
}
catch(...)
{
// handle error
}

Then i close the file as follows:

try
{
outputFile.Close();
}
catch (CFileException* fileException)
{
// handle error
}
catch(...)
{
// handle error
}

Neither CStdioFile::WriteString not CFile::Close() throw any
exception.
I have read the MSDN documentation of CStdioFile::WriteString(). It
says that this method will throw a CFileException in case of disk
full.

Another strange thing i have observed is that if the disk space is
less than or equal to 4 KB then disk full CFileException is thrown.
But not by CStdioFile::WriteString() instead by CFile::Close() which
follows in my code above. That is presicely the reason why i have
outputFile.Close() inside try catch block.

Can some one help me please.

Thank you very much in advance.

Best Regards,
Syed Khadeer.
From: thatsalok on
How could you be so particular the space left in target Drive is 8kb only
"Syed Khadeer" <Khadeer123(a)yahoo.com> wrote in message
news:3a5aa13.0502110750.6dc829c2(a)posting.google.com...
> Hello,
> I am facing problem with usage of CStdioFile::WriteString method.
> The problem is as follows:
>
> There is only 4 to 8 KB of disk space left in the target directory.
> I have a CString variable containing about 12KB of data.
> I open a ASCII file using CStdioFile as follows:
>
> CFileException exception;
> CStdioFile outputFile;
> if (!outputFile.Open(m_strFilePath, CFile::modeCreate |
> CFile::modeWrite | CFile::shareExclusive | CFile::typeText))
> {
> // handle error here
> }
>
> then attempt to write to the file as follows:
> try
> {
> outputFile.WriteString(strValue);
> }
> catch (CFileException* fileException)
> {
> // handle error
> }
> catch(...)
> {
> // handle error
> }
>
> Then i close the file as follows:
>
> try
> {
> outputFile.Close();
> }
> catch (CFileException* fileException)
> {
> // handle error
> }
> catch(...)
> {
> // handle error
> }
>
> Neither CStdioFile::WriteString not CFile::Close() throw any
> exception.
> I have read the MSDN documentation of CStdioFile::WriteString(). It
> says that this method will throw a CFileException in case of disk
> full.
>
> Another strange thing i have observed is that if the disk space is
> less than or equal to 4 KB then disk full CFileException is thrown.
> But not by CStdioFile::WriteString() instead by CFile::Close() which
> follows in my code above. That is presicely the reason why i have
> outputFile.Close() inside try catch block.
>
> Can some one help me please.
>
> Thank you very much in advance.
>
> Best Regards,
> Syed Khadeer.