Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 
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?
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 27-Nov-12 21:25pm
lilyNaz536
Edited 27-Nov-12 22:34pm
v2
Comments
armagedescu at 28-Nov-12 5:47am
   
Is there thrown a EInOutError or EInOutError& ? Or EInOutError* ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
lilyNaz at 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 at 1-Dec-12 1:59am
   
Just to check if c++ exception is properly thrown use catch(...) instead for testing
lilyNaz at 1-Dec-12 3:47am
   
I used catch(...) and next time I used catch(Exception &e) but I got the same exception.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I used SHBrowseFolder instead and everything turned out OK.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100