Solved

File deletion problem...

Posted on 2000-04-20
5
136 Views
Last Modified: 2010-04-04
I use this kind of code:

  IF (Key = VK_DELETE) And Assigned(DirView1.Selected) And Not DirView1.isEditing Then
  begin
  DirView1.DeleteSelectedFiles(Not(ssShift in Shift));
  end;

This code is working fine. But now i don't know why it raises exception EInOutError with message 'File not Found'. And leaves file in the DirView list.
If i delete with this code directory then it works fine.

mhieta
0
Comment
Question by:mhieta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 50 total points
ID: 2734040
Try doing this instead:

IF (Key = VK_DELETE) And Assigned(DirView1.Selected) And Not DirView1.isEditing Then
  begin
    TRY
      DirView1.DeleteSelectedFiles(Not(ssShift in Shift));
    EXCEPT

    END;
    DirView1.Refresh;
  end;

It might not solve your 'File not found' problem but it will stop the code reporting nasty errors. To get around the problem of 'File Not Found' then check the name and path of the file(s) you are trying to delete. This could be a missing '\' character or a sub-path not being added correctly. Just add a ShowMessage before the delete and see what it's doing

The Neil =:(
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2734069
Neil. i think try except is the best thing in Delphi, it shuts it up to say the least!... :)
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2734081
If isn't complaining then it must be ok - I like this approach...

The Neil =:)
0
 
LVL 3

Expert Comment

by:f15iaf
ID: 2734609
maybe file has a "read only attribute"
0
 
LVL 2

Author Comment

by:mhieta
ID: 2737219
Thanks! The Neil,

I use Filemanager toolset For Delphi 4. So i see message when i delete files or directories.
You are right that it will stop the code reporting nasty errors.

mhieta
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question