Click here to Skip to main content
11,417,750 members (47,061 online)
Rate this: bad
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
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 ( IO_WriteOnly | IO_Translate ) )
      // File Writting code will go here....
      qDebug( "Could not create file");
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)

  Print Answers RSS
0 Sascha Lefévre 340
1 Abhinav S 339
2 OriginalGriff 315
3 Sergey Alexandrovich Kryukov 255
4 deepankarbhatnagar 121
0 Sergey Alexandrovich Kryukov 9,345
1 OriginalGriff 7,712
2 Maciej Los 3,758
3 Abhinav S 3,601
4 Sascha Lefévre 3,198

Advertise | Privacy | Mobile
Web02 | 2.8.150427.4 | Last Updated 28 Feb 2011
Copyright © CodeProject, 1999-2015
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