PDA

View Full Version : How to write file in the selected path.



merry
19th July 2007, 08:03
Hi all

Me working on Qt4.2 for MAC O.S

Can anybody tells me that how can I write my own file in the selected path from the QFiledialog through Qt Programming;

Thanx

merry
19th July 2007, 08:30
Hi

For eg.


FILE *fh = NULL;
fh=fopen("/path","wb+");
the above file named "path" is created in the harddisk.

but I want to create this file on that path selected by me using QFiledialog which is stored in a string.



QString m_dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly
|QFileDialog::DontResolveSymlinks);

vishal.chauhan
19th July 2007, 08:34
Hi,

you can do like this.

QString FileName= QFileDialog::getSaveFileName(this,"",Save","YrFileName","");

fopen((const char*)FileName.toAscii() ,"wb+")

It will save the file YrFileName to the selected Path

jpn
19th July 2007, 10:21
QFile - do I need to say more? :)