Sign in to follow this  
Followers 0
Shawndt

Deleting Files

9 posts in this topic

I've noticed that I cannot delete read-only files with FILEDELETE. Is there away too get around this?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <Process.au3>
_RunDOS ( "DEL ""C:\1.txt""" )

Untested

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites

#include <Process.au3>
_RunDOS ( "DEL ""C:\1.txt""" )

Untested

The include file, does it have to be on the machine or when you create the .exe file?

Share this post


Link to post
Share on other sites

It has to be on the machine when you create the exe, but it doesn't need to be with the exe after it's created.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

should already be on the machine (unpacked in the include folder when autoit installed) just make sure to add that line to the top of your code if you use the _RunDOS function


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

it bombs

Share this post


Link to post
Share on other sites

Try it:

$sFileToDelete = @DesktopDir & '\DeleteReadOnlyFile.txt'

If StringInStr(FileGetAttrib($sFileToDelete), 'R') Then FileSetAttrib($sFileToDelete, '-R')
$iRet = FileDelete($sFileToDelete)

Danny, thanks so much for your help. Got another question. I am checking to see if a fileexist which is simply but i cannot find the Syntax to Check for Directory?

Share this post


Link to post
Share on other sites

you can use FileExists to check for files and folders

FileExists ( "path" )

Parameters

Path The directory or file to check.

Return Value

Success: Returns 1.

Failure: Returns 0 if path/file does not exist.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0