stylonurus
Programmer
I am creating a TComboBox which will contain a historical list of the last 10 IP addresses entered by the user. At startup, I check to see if the file where I save these addresses exists. I create it if it doesn't. If it does I load the previously saved list.
The previous segment works and creates the file. The problem is when I try to update the list with a saveToFile call after the user enters an IP address.
I get this exception on the SaveToFile call above:
raised exception in class EFCreateError with message ' Cannot create file C:\NuVasive\RemoteReader\IPLIST.DAT' Process stopped.
But the file was created at startup and
This problem only happens on the first time when no list exists. The next time I run it I get no error and the Save and Load functions work perfectly. Does anyone have a clue why the first initial run causes problems. And of course since I'm kind of new to this programming environment any programming tips are more than welcome.
Thanks so much
Rick Eis
Code:
char const = *ComboFNpath "C:\\NuVasive\\RemoteReader\\IPLIST.DAT";
// check for existence of file
if ( !FileExists(ComboFNpath) ) {
// create file
FileCreate(ComboFNpath);
}
else {
Form1->ComboBox1->Items->LoadFromFile(ComboFNpath);
// Insert first item in list into viewable area
Form1->ComboBox1->Text = Form1->ComboBox1->Items->operator [](0) ;
}
Code:
if ( ( idx = Form1->ComboBox1->Items->IndexOf(Form1->ComboBox1->Text) ) >= 0 ) {
// If present, move that item to top of list and perform connect
Form1->ComboBox1->Items->Insert(0,Form1->ComboBox1->Text);
Form1->ComboBox1->Items->Delete(idx+1) ;
Form1->ComboBox1->Text = Form1->ComboBox1->Items->operator [](0) ;
Form1->ComboBox1->Items->SaveToFile(ComboFNpath);
strcpy(DestinationAddress,Form1->ComboBox1->Text.c_str());
DestinationType = FALSE;
}
raised exception in class EFCreateError with message ' Cannot create file C:\NuVasive\RemoteReader\IPLIST.DAT' Process stopped.
But the file was created at startup and
This problem only happens on the first time when no list exists. The next time I run it I get no error and the Save and Load functions work perfectly. Does anyone have a clue why the first initial run causes problems. And of course since I'm kind of new to this programming environment any programming tips are more than welcome.
Thanks so much
Rick Eis