Delete File

Because when I want to erase a file with:

AssignFile(f, 'Correspondencia.mb'); Erase(f);

It appears the error " File Access Denied "? as I can erase the file without it appears east error? or as it is the possible cause of this error.


jara_vlaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
The file may be opened by another program, or you may not have sufficient user rights to delete the file.

Try deleting it by hand from withinExplorer.

Cheers,

Raymond.
0
jara_vlaAuthor Commented:
with the Explorer  
if it I can erase
 
0
rwilson032697Commented:
Which line gives you the error? The assign or the erase...

Cheers,

Raymond.
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

MotazCommented:
Check file attributes (Read only, Hidden, and System) it's attributes must not be one of these above. Check also that you do not open this file, if you did check that you close it.

Motaz
0
MadshiCommented:
Why not using

DeleteFile('Correspondencia.mb');

?

And perhaps you should give in the file path, too...

E.g.

DeleteFile('C:\Path\Correspondencia.mb');


Regards, Madshi.
0
intheCommented:
did you try :

DeleteFile(c:\'Correspondencia.mb');
0
wimmeyvaertCommented:
I suppose the reason why you get the error is because the function AssignFile makes an association to the specified filename.
So, as long as this association exists, you can't delete the file.

The correct way to delete a file from disk is to use the function DeleteFile :
  if not DeleteFile('Correspondencia.mb') then
    ShowMessage('file can't be deleted.')
  else
    ShowMessage('file deleted.');


0
MotazCommented:
AssignFile(f, 'Correspondencia.mb'); Erase(f); is valid, you can not Erase the file without assigning.

Motaz
0
Ronald BusterOwnerCommented:
Hi it can be made simple use the function :

function DeleteFile(const FileName: string): Boolean;

eg.

if DeleteFile('correspondencia.mb') then
  showmessage('file deleted');
else
  showmessage('error deleting file');
end if

hope this helps

regards,

cono
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intheCommented:
hi madshi great timing :-)

cono are you blind?
0
jara_vlaAuthor Commented:
ok thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.