Solved

File deletion problem...

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

20 Experts available now in Live!

Get 1:1 Help Now