Jump to content

File Management


anixon
 Share

Recommended Posts

I have been experiencing a Windows/Notebook.exe in that application when opening a file created by AutoIT and 'Access Denied' situation because the files Windows privileges no longer give the origionator/user of the file or an user with administrator privileges access. In addition whilst the AutoIT script is running you are unable to delete the corrupt file.

The uncorrupt file being corrupted is during a process being assigned to a variable as an email attachement for example:

$EmailAttachment = @scriptdir & "fileattachment.txt"

Before it is passed to a CDO processes it is possible that the script updates the 'fileattachment.txt" which has already been assigned to an unprocessed variable. The email and its attachcment is received by the recipient but the fileattaqchment.txt is corrupt and cannot be deleted with the command filedelete(@scriptdir & "fileattachment.txt")

even with full access privileges using fileattribute(@scriptdir & "fileattachment.txt", "-R") and then delete makes no difference.

The simply question is this process the cause of the file being corrupted.

Replies are always appreciated Ant..

Link to comment
Share on other sites

Hi,

1) See helpfile @ScriptDir:

@ScriptDir

Directory containing the running script. (Result does not contain a trailing backslash)

-> filedelete(@scriptdir & "\fileattachment.txt")

2) You may have an open file by the script -> e.g. $file = FileOpen ("fileattachment.txt", 2). If you don't close the filehandle (FileClose ($file)) before the FileDelete, you can't delete the file.

;-))

Stefan

Edited by 99ojo
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...