Greetings from Greece, this is my first post!
I'm having some minor trouble with an application I've been working on the past week. So if you could please shed some light into this.
Thank you.
The problem I'm having is that when the user is trying to save a file something goes wrong. Let me explain.
Once the program starts a new file is created called "unsaved.txt", its name taken from a main.h global char* variable.
If the program exits, the "unsaved.txt" file is automatically deleted, if ofcourse it's still there.
Now what the 'save' function does is change the file name so that it is not deleted when the user exits.
The problem here is that although I manage to rename the file name from "unsaved.txt" to whatever the user enters, the global char* variable (fileName) won't change and remain "unsaved.txt" so the next time I try to write something new into this file it will still create a new "unsaved.txt".
Take a look at this and please let me know if I'm doing anything wrong.
The 'saveFunction' :
if (!fileNameEdit->Text.IsEmpty()) {
String newFileName = fileNameEdit->Text + ".txt";
rename( "unsaved.txt", newFileName.c_str() );
fileName = newFileName.c_str();
this->Close();
}
else {
Application->MessageBox("Please enter a file name.", MB_OK | MB_ICONEXCLAMATION);
}