Solved

Delete Hidden files

Posted on 2000-03-01
11
207 Views
Last Modified: 2010-04-04
When I use the DeleteFile(filename) function, it does not delete hidden files - so how can I do this?  I also remember a question about deleting files so they cannot be recoved by programs like the dos undelete.exe program, so could you help me on that?

Cheers
0
Comment
Question by:bogieman_
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 2

Accepted Solution

by:
aubs earned 100 total points
ID: 2572950
Use the SetFileAttributes command before trying to delete the file.

SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
0
 
LVL 1

Author Comment

by:bogieman_
ID: 2573117
I want to remove many files at once as fast as possible - so does it take long to execute that command?
0
 
LVL 2

Expert Comment

by:aubs
ID: 2573420
I've no idea!

Maybe you could try to using the deletefile command then only use SetFileAttributes if it fails.

Aubs
0
 
LVL 17

Expert Comment

by:inthe
ID: 2574841
hi,
why not before the deletion make all files not hidden , then after deletion hide them again.
i can send example for this as i made a demo once for similar which does same as explorers dialog to show or hide files.
0
 

Expert Comment

by:skycrusher
ID: 2574883

if the files are in the same directory,
maybe you can use this function:

BOOL RemoveDirectory(LPCTSTR lpszDir)

refer to Delphi's Help for more information about this function.

Regards,
skycrusher

0
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.

 

Expert Comment

by:akarasev
ID: 2575159
You need to call Interrupt 21h Function 7141h. It must look like:

asm
 mov ax, 7141h    
 mov ch, 00h
 mov cl, 02h      
 mov dx, seg Filename      
 mov ds, dx
 mov dx, offset Filename
 mov si, 1  
 int 21h
end;

Regards.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2575846
asm dont work in nt ...
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 2576070
Yes it does!  I use it regulary!

John.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2576202
er ok it may work im mixed up between interupts and hardware ..

0
 
LVL 1

Author Comment

by:bogieman_
ID: 2580629
I think I might just use aubs first suggestions - I am using a Tsearchrec to find certain files and delete them, so I can do this:

if (TheSearchRec.attr or fahidden >0) //I think that's right
then begin
SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
deletefile(TheSearchRec.filename);
end else deletefile(filename);

But I havn't tested it
0
 
LVL 2

Expert Comment

by:aubs
ID: 2596443
I think you mean:

if (TheSearchRec.attr AND faHidden >0) then
  SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
Deletefile(Filename);  


Bear in mind that SearchRec.Name will only return the filename and extension - not the path!!!


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
Delphi OLE Error 8 93
calling procedure inside activexForm from secondform 1 231
ddeman not working in activex 3 92
Syntax Check Delphi Seattle IOS app without MAC ? 1 89
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…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

12 Experts available now in Live!

Get 1:1 Help Now