How to stop user from deleting/modifying our application's files?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

my pocket pc application generates some output files and it also make use of
some configurable input files(both text files). After starting my program,
if any user deletes my input files/output files, my application will not work
smoothly and anything unexpected can happen.

it may be similar to complaining to Microsoft that Windows is not working
properly, after deleting the entire Windows system directory?

Still, I search for an answer. How can we stop the user from deleting or
modifying all our application's files. Or how to deny access to our
application's folder?

I wish t know, how all other developers have tackled this situation?

Regards,
hari
 
Generally speaking, I'd treat that scenario the same as if a user deleted
your exe. How will your app work then? In any case, you should have default
values for anything you read from a file, registry or wherever. At startup,
try to obtain the input and when it fails your code falls back to the
hardcoded default(s).

Cheers
Daniel
 
Whenever Mr.Daniel is there, we, developers are confident.

Could you please elaborate on denying access to particular folders/files?
 
Sorry Hari, it seems my previous post was not clear. My suggestion is not to
worry about users deleting your files. If they do, fallback to hardcoded
defaults in your application so you don't rely on the input files being
there.

Now if you really need to cater for that scenario, here are some random
suggestions (I've never had to do that myself):

1. Mark the files as ReadOnly. If you need to change that setting when your
app is running, change it and then change it back when your app exits. Look
up System.IO.FileAttributes.ReadOnly for this.
2. Mark the files as system files or as Hidden (same as 1,
System.IO.FileAttributes.Hidden)
3. Instead of using files, use the registry as your store which is harder
for the user to mess with.
4. And a more radical approach, embed the input files in the assembly. On
startup check to see if the files are on the system and if they are not,
extract them from your assembly and use them. This was discussed recently in
a different context but the principle is the same (look at Alex Feinman's
contribution):
http://groups-beta.google.com/group..._doneTitle=Back+to+Search&&d#4828bba550894d45

Cheers
Daniel
 
Daniel Moth said:
Sorry Hari, it seems my previous post was not clear. My suggestion is not
to worry about users deleting your files. If they do, fallback to
hardcoded defaults in your application so you don't rely on the input
files being there.
[Cut]

Good point. One of the big issues on the pocket pc is to ensure that your
application always work. One way to do this is to try to cut the users off
from modifying the device settings, manipulating files and
removing/installing additional application. Where there is a will there is a
way and the most "devious" will find a way.

My approach is to use default settings (inifile + registry) where none
exist; auto install my application at start up if not installed; autorun a
full screen application at startup (if installed); saving basic files in a
flash folder; finally I consider to Flash my install application into ROM.

Creating an enviroment for an end user application that will always work is
a task in its own.
 
Back
Top