Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have written a code in C++ builder in which I use header FileCtrl.hpp and I call SelectDirectory procedure so that the user can choose the a directory. When I change the drive to empty floppy disk or DVD drives, I get Exception EInOutError. I used try catch, bu it didn't work.

C++
try{
   SelectDirectory(path, TSelectDirOpts(), 0);
}catch (EInOutError &exception)
{
   Application->ShowException(&exception);
}

Then I looked at the procedure in FileCtrl.pas responsible for drive change and I modified it but again nothing changed, I still get the exception.What Should I do?
Delphi
procedure TDirectoryListBox.DriveChange(NewDrive: Char);
begin
  if (UpCase(NewDrive) <> UpCase(Drive)) then
  begin
  if NewDrive <> #0 then
    begin
        {$I-}
       ChDir(NewDrive + ':');
      if IOResult<>0 then
      begin
        {$I+}
        MessageDlg('Warning', mtWarning, [mbOk], 0);
        Exit;
      end;
      {$I+}
      GetDir(0, FDirectory);
    end;
    if not FInSetDir then
    begin
      BuildList;
      Change;
    end;
  end;
end;
Posted
Updated 27-Nov-12 22:34pm
v2
Comments
armagedescu 28-Nov-12 5:47am    
Is there thrown a EInOutError or EInOutError& ? Or EInOutError* ?

To trap EInOutError enable "I/O checking" in the Pascal tab of the project options in order for EInOutError exceptions to be trapped. It seems EInOutError is a delphi class
 
Share this answer
 
Comments
lilyNaz 1-Dec-12 0:44am    
I have enabled the I/O checking in the Delphi Compiling Options But I get this very exception.
Dharmateja Challa 1-Dec-12 1:59am    
Just to check if c++ exception is properly thrown use catch(...) instead for testing
lilyNaz 1-Dec-12 3:47am    
I used catch(...) and next time I used catch(Exception &e) but I got the same exception.
I used SHBrowseFolder instead and everything turned out OK.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900