Sign in to follow this  
Followers 0
Pieter

Marking a file as 'in use'

5 posts in this topic

How do I mark a file as 'in use' so that Windows can't delete/change it as long as the program is running? I'm trying to lock my configuration file so that the program won't begin acting weird suddenly.


iPod + Online calendars = iPodCALsync

Share this post


Link to post
Share on other sites



Hmm in what instance would 'windows' want to remove an innocent file?

Anyway, probably setting its attribute would help. FileSetAttrib

Share this post


Link to post
Share on other sites

If you open for Write-access, windows stops it from being deleted or renamed etc. Try different open modes for your specific purposes

:P

Share this post


Link to post
Share on other sites

FileSetAttrib

--------------------------------------------------------------------------------

Sets the attributes of one or more files.

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse])

Parameters

file pattern File(s) to change, e.g. C:\*.au3, C:\Dir

+-RASHNOT Attribute(s) to set/clear. e.g. "+A", "+RA-SH"

recurse [optional] If this is set to 1, then directories are recursed into. Default is 0 (no recursion).

Return Value

Success: Returns 1.

Failure: Returns 0 if encountered any errors.

Remarks

The file pattern cannot contain spaces!

The attributes that can be modified with the function are + or -:

"R" = READONLY

"A" = ARCHIVE

"S" = SYSTEM

"H" = HIDDEN

"N" = NORMAL

"O" = OFFLINE

"T" = TEMPORARY

(Note that you cannot set the compressed/directory attributes with this function.)

Write-only access is not listed. Am I looking on the wrong page?

iPod + Online calendars = iPodCALsync

Share this post


Link to post
Share on other sites

FileOpen ( "filename", mode )

Parameters

filename Filename of the text file to open.

mode Mode (read or write) to open the file in.

Can be a combination of the following:

0 = Read mode

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

4 = Read raw mode

8 = Create directory structure if it doesn't exist (See Remarks).

Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8' - See Remarks).

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