PDA

View Full Version : Processing on the File



amiref
27th March 2011, 19:51
Hi
I want to open the file that is in a place in my computer . I use this code but it doesn't open it . How can I open that file ?




QString path = "C:\Program Files (x86)\vnb.txt" ;
QFile inFile( path );
if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text))
return -1 ;

Zlatomir
27th March 2011, 20:06
That is most likely because your path is not good, remember that you are still using C++ and \ is an escape character, so you need to double it in a string, try it like this:

QString path = "C:\\Program Files (x86)\\vnb.txt" ;
Doesn't your compiler warn about unknown escape characters?