Solved

File deletion problem...

Posted on 2000-04-20
5
138 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

Independent Software Vendors: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

615 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