Solved

File deletion problem...

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Delphi function to get Youtube video title 5 227
proper way to parse url in delphi 2 165
FMX StringGrid1->Canvas->FillRect Problem 3 128
Convert a string into a TDateTime 5 52
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now