Solved

Protect a file from being deleted

Posted on 2014-11-16
10
91 Views
Last Modified: 2014-11-17
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:
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

Open in new window

0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40446222
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.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40446224
What happens if the file is deleted?
0
 

Author Comment

by:isnoend2001
ID: 40446263
The file is encrypted and reads:
"Not Registered" or
"refunded" or
"yes Registered"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:Martin Liss
ID: 40446273
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".
0
 

Author Comment

by:isnoend2001
ID: 40446482
Thanks Martin, I thought writing to the registry was a problem when Vista came out,No ?
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40446489
I don't really know but see this EE solution. If I were you I would create a small new project just to try it out and if you need more help I guess you'll need to ask a new question because I use XP.
0
 

Author Closing Comment

by:isnoend2001
ID: 40446513
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
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40446523
OK if you have other questions concerning your 1 and 2, ask a new question and I or others will try to help
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40447019
"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.
0
 

Author Comment

by:isnoend2001
ID: 40447355
I agree the registry was easy until vista
the  http:#a40446489 answer provided a link for info that reinforced what i thought
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 43
how to know if my Checkbox is True in VB6.0? 9 65
Advice in Xamarin 21 109
Dinamic report to Crosstab query 9 52
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question