Click here to Skip to main content
16,015,991 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to create a file in the hard-disk in QT?? Checking whether the hard disk exists or not???
Posted

1 solution

#include <qfile.h>
#include <qtextstream.h>

QString strfilename = "C:\\Sample.txt";

QFile pfile( strfilename );

if ( pfile.open( IO_WriteOnly | IO_Translate ) )
{
// File Writting code will go here....
}
else
{
qDebug( "Could not create file");
}
 
Share this answer
 
v2
Comments
Gokulnath007 28-Feb-11 0:58am    
Not C drive or D drive.. If the hard-disk is not partitioned, just finding if that hard-disk exists or not???
Harrison H 1-Mar-11 18:07pm    
Don't forget, if you're using a cross platform framework, write cross-platform code!

Chage "C:\\Sample.txt" to "C:/Sample.txt" !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900