Advertisement Jump to content
Sign in to follow this  
en972

Help with text editor. Save problems

This topic is 4911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a text editor (used with Borland C++ Builder 6) and everything was running find until I had to create a save function (or event handler). My save as event handler works great, but just plain save screws up. I get a pop up window error when I click save that says
 Project TextEditor.exe raised exception class EFCreateError with message 'Cannot create file'. Process Stopped. Use Step or Run to continue.
Here is my code:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FileNewExecute(TObject *Sender)
{
RichEdit1->Clear();
FileName = "untitled.txt";
StatusBar1->Panels->Items[0]->Text = FileName;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
RichEdit1->Lines->LoadFromFile (FileOpen1->Dialog->FileName);
FileName = FileOpen1->Dialog->FileName;
StatusBar1->Panels->Items[0]->Text = FileName;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileSaveExecute(TObject *Sender)
{
if (FileName == "untitled.txt")
    FileSaveAs1->Execute();
else
    RichEdit1->Lines->SaveToFile(FileName);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FileSaveAs1BeforeExecute(TObject *Sender)
{
FileSaveAs1->Dialog->InitialDir = ExtractFilePath (FileName);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FileSaveAs1Accept(TObject *Sender)
{
FileName = FileSaveAs1->Dialog->FileName;
RichEdit1->Lines->SaveToFile(FileName);
StatusBar1->Panels->Items[0]->Text = FileName;
}
//---------------------------------------------------------------------------
Please help

Share this post


Link to post
Share on other sites
Advertisement
Put a breakpoint right before the save. Check what name you're trying to create. Figure out why that name is wrong.

Also, put a breakpoint right before the save, and then enable the debugger feature that makes it break on all exception throws, so you can see where the exception is being thrown from.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!