Your code should work, i.e. (modification from Your previous post, tested on winXP SP3):
QString outputDir
= QDir::currentPath();
// with "/" separators QString fileName
= QString( "%1%2" ).
arg("some_file_name").
arg( ".dat" );
QString fileOut
= outputDir
+ "/" +fileName;
qDebug() << "Could not create Project File";
}else{
qDebug() << "Opened: " << fileOut;
}
QString outputDir = QDir::currentPath(); // with "/" separators
QString fileName = QString( "%1%2" ).arg("some_file_name").arg( ".dat" );
QString fileOut = outputDir+ "/" +fileName;
QFile file( fileOut );
if (!file.open( QIODevice::WriteOnly )) {
qDebug() << "Could not create Project File";
}else{
qDebug() << "Opened: " << fileOut;
}
To copy to clipboard, switch view to plain text mode
outputs:
Opened: "C:/Qt/.../some_file_name.dat"
Windows can handle slash (c:/path/to/file.txt) and backslash (c:\path\to\file.txt) (try it in explorer).
You can even do something crazy like this:
QString fileOut
= outputDir
+ "\\" +fileName;
QString fileOut = outputDir+ "\\" +fileName;
To copy to clipboard, switch view to plain text mode
outputs:
Opened: "C:/Qt/...\some_file_name.dat"
If you use QtCreator do Build->Clean All / Clean Project (maybe some moc file are interfering), check if file is not used by any other app (if You work with existing files), check Your permission (and app) to the directory that You write file into.
Bookmarks