Click here to Skip to main content
12,999,081 members (48,836 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to create a file in the hard-disk in QT?? Checking whether the hard disk exists or not???
Posted 27-Feb-11 18: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.170622.1 | Last Updated 28 Feb 2011
Copyright © CodeProject, 1999-2017
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