Click here to Skip to main content
11,928,605 members (52,441 online)
Rate this:
Please Sign up or sign in to vote.
See more: VC8.0 C++
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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | 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