isnoend2001
asked on
Protect a file from being deleted
How can i create a file and make it where it cannot be deleted
Like windows does with a message
"access denied" ?
file is created like this:
Like windows does with a message
"access denied" ?
file is created like this:
Public Sub SaveTextFile(sFileName As String, txt As String)
Dim ff As Integer
ff = FreeFile
Open sFileName For Output As #ff
Print #ff, txt
Close #ff
End Sub
You can make a file read-only via code but that won't prevent someone from going to Widows Explorer and changing that. IMO your best bet is to hide it, but even then it can be found and deleted.
What happens if the file is deleted?
ASKER
The file is encrypted and reads:
"Not Registered" or
"refunded" or
"yes Registered"
"Not Registered" or
"refunded" or
"yes Registered"
I would put the encrypted value in the Registry where it's less prone to erasure rather than a file and in either case if not found I'd assume that the app is "Not Registered".
ASKER
Thanks Martin, I thought writing to the registry was a problem when Vista came out,No ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Martin
I Also use xp, but have another computer with win7 just for testing.
Using the registry is too complicated and error prone
i have though o a few work arounds that turn into dead ends
1. open the file when the app closes, but don't close the file. This may keep a reference to the file, not sure, but the next time the computer starts it will no longer work.
2. determine if there is any way to write a value to the resource file
I Also use xp, but have another computer with win7 just for testing.
Using the registry is too complicated and error prone
i have though o a few work arounds that turn into dead ends
1. open the file when the app closes, but don't close the file. This may keep a reference to the file, not sure, but the next time the computer starts it will no longer work.
2. determine if there is any way to write a value to the resource file
OK if you have other questions concerning your 1 and 2, ask a new question and I or others will try to help
"Using the registry is too complicated and error prone" - are you serious? It is less error prone than using a file, and not at all complicated once you have set it up correctly. Just three or four lines of code required.
On the other hand, accepting http:#a40446489 seems to be off, if you can't use the suggestion.
On the other hand, accepting http:#a40446489 seems to be off, if you can't use the suggestion.
ASKER
I agree the registry was easy until vista
the http:#a40446489 answer provided a link for info that reinforced what i thought
the http:#a40446489 answer provided a link for info that reinforced what i thought