Solved

Delete Hidden files

Posted on 2000-03-01
11
210 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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
 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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