Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0
How to create a file in the hard-disk in QT?? Checking whether the hard disk exists or not???
Posted 27-Feb-11 19:30pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

#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");
}
  Permalink  
v2
Comments
Gokulnath007 at 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 at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 28 Feb 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100