0

I'm writing a little application for a college final. This app will be a desktop app for windows 7, both 32 and 64bits.

My questions are the following, i hope i make them clear:

1) What's the recommended/standard path to store external files? images, sql scripts, documents (word, pdf, etc)

2) What's the recommended/standard approach to protect those files? i mean, protect them from user deletion, external deletion(malware or something). ie, where should i put the user's manual for my software and how would i protect it against the user deleting it or if that happened how would i restore the file?

also if posible please provide any code that would help me achieve the solutions.

HardCodeStuds
  • 407
  • 2
  • 11
  • 29
  • Have you tried anything? For a web application you would probably store images inside a `~/Content` folder, whereas scripts go into a `~/Scripts` folder. Generally it's a matter own personal preference, but those two are the defaults for asp.net mvc project template. We do not just supply you code, you have to show some effort. – scheien May 23 '14 at 06:29

2 Answers2

2

Files that belong to the application and are not supposed to be altered go to the installation folder. Normally, that resides in C:\Program files\YourCompany\YourApplication but the installing user may select another path.

It's not your job to protect your applications' files. If someone with enough privileges wants to delete or change them after the installation, so be it. The operating system will not let everybody delete files in the default program folder but if the user has the privileges or the installing user put them where everybody has those privileges, that's not your concern.

You can use tools like wix to create professional installers.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • your answer gave me a lot to think about, but i still want to protect those files to assure integrity of the app.. what if the user choses another installation path and deletes an image or a document that was meant to be shown when the user performed an action? – HardCodeStuds May 23 '14 at 08:18
  • 1
    If you want to be nice, you could let your application check the integrity of your resources and present a nice error message to reinstall to your user. But in the end, you cannot hinder the user from damaging your application. If he really wants to, he will trash his PC with an axe. The resource files will be gone and there is nothing you can do to prevent this. – nvoigt May 23 '14 at 08:41
2

You can add these contents (images, sql scripts, documents, etc) as project resources.

You can access these resource items using

<dataType> variable = <project>.Properties.Resources.<ResourceName>;

e.g.

Bitmap logoImage = myProject.Properties.Resources.Logo;
string welcomeMessage = myProject.Properties.Resources.WelcomeMessage;
//etc...

The above process will embed your external files into your assemblies' resource section. They will become integral part of your application.

References:

Community
  • 1
  • 1
Manish Dalal
  • 1,768
  • 1
  • 10
  • 14
  • yeah i know i can embedd them as resources but what if for example there's certain file created after installation that i need. How can i protect it?, that was my question. – HardCodeStuds May 23 '14 at 08:20
  • @HardCodeStuds, in the original question you didn't mention that files will be created after installation. In that case it should be the responsibility of the user to ensure files remain intact. At the most your application can lock the files when the app is running, but what after when the application closes? Tell me what can Microsoft Word (or any other application) do if a file it needs is deleted by the user?..... – Manish Dalal May 23 '14 at 09:14