What i want to know is how do i rename an 'old' file into what the user have typed to be saved as. For example, in my case i automatically duplicate a .bmp file named 'New.bmp' whenever the user open an image. so after editing the image and all that, the user wants to save the new image and he or she can type her own file name such as john.bmp to be saved as. so what happened is this modified image goes to New.bmp(duplciated one) and when i check the location of the files, it create both New.bmp AND john.bmp but for john.bmp it has 0 bytes. Can someone pls advise me on whats wrong? my code is posted below. Code: void CLEO_MedivisionView::OnFileSaveas32819() { // TODO: Add your command handler code here FILE *fs; errno_t err; static CString szFilter; char hdr[3]; char String[30]; int i; long position = 0; unsigned short sav_data; szFilter = "BMP (*.bmp)|*.bmp||"; CFileDialog FileSavedlg(FALSE, LPCTSTR("bmp"), NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, LPCTSTR(szFilter)); if (FileSavedlg.DoModal() == IDOK) { pen = false; man_segment_select = false; //Don't set the flag for Selecting region manually for Segmentation const size_t StringSize = 100; size_t CharactersConverted = 0; char filename[StringSize]; wcstombs_s(&CharactersConverted, filename, FileSavedlg.GetFileName().GetLength()+1, FileSavedlg.GetFileName(), _TRUNCATE); if ((err = fopen_s(&fs, filename, "wb+")) != 0) { printf("Cannot open binary file. "); fclose(fs); } else { //**************************************************************************************** if (bmp_count == 24){ if (no_of_rows == 256 && no_of_cols == 256) { for (i=0; i<256*256; i++) { fputc (image256[i], fbmap2); fputc (image256[i], fbmap2); fputc (image256[i],fbmap2); } } else if (no_of_rows == 512 && no_of_cols == 512) { for (i=0; i<512*512; i++) { fputc (image[i], fbmap2); fputc (image[i], fbmap2); fputc (image[i], fbmap2); } } } else if (bmp_count == 8){ if (no_of_rows == 256 && no_of_cols == 256) { for (i=0; i<256*256; i++) { fputc (image256[i], fbmap2); } } else if (no_of_rows == 512 && no_of_cols == 512) { for (i=0; i<512*512; i++) { fputc (image[i], fbmap2); } } } } //**************************************************************************************** fclose(fbmap2); system("copy New.bmp one.bmp"); remove("New.bmp"); } }