Solved

File deletion problem...

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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