1

After installing my application on a clients machine, How can I securely hide files used by my program from the user? Such as pdf's and video files. I am using C# and windows forms in Visual Studio 2013.

leppie
  • 115,091
  • 17
  • 196
  • 297
Lance
  • 19
  • 5
  • 3
    Lookup Embedded Resources in Assemblies. – Matt Jan 16 '15 at 08:24
  • 1
    If there is a lot of content and you don't want to bloat your assemblies out with embvedded resources, you will need to look in to encryption. [C# Encryption](http://support.microsoft.com/kb/307010/en-gb) – Murray Foxcroft Jan 16 '15 at 08:32
  • there is a lot of files but if I encrypt them I have to decrypt a file and store it on disk every time I need to open the file right? then the user can access it while my program is using it. – Lance Jan 16 '15 at 09:02
  • What you ask is in most cases not done. I can't recall any piece of software that goes to extreme length to hide installed media files. They don't want anyone to debug the code, but that's all. So, the question is why do you want this? – Dialecticus Jan 16 '15 at 11:52
  • All the program basically does is shows users the files. If they can see the files without the program then the program is useless. If I sell the files without a program, users can just share them for free without having to buy them – Lance Jan 16 '15 at 14:47

3 Answers3

1

Another option would be using a ZIP Package (see MSDN). You can store your files in the package with CompressionOption.SuperFast or even CompressionOption.NotCompressed to maximize performance. All your files will be located in that package, and you will be able to modify and save them back. Unfortunately, there is no option to encrypt nor password protect the package, and the user will be able to "open" your package in a ZIP tool (or even via Explorer), if he or she knows the file name and does understand that file extension doesn't matter.

dymanoid
  • 14,771
  • 4
  • 36
  • 64
0

As Matt commented, Embedded Resources is a way. Just remember that if you're currently navigating to your files (e.g. c:\MyApp\MyFile.pdf), you will not be able to do that anymore if you change these files to Embedded Resources.

Have a look at this Question.

You may also consider creating a Resource file (.resx) and adding your pdf's and videos into the resource file.

Community
  • 1
  • 1
Niels Filter
  • 4,430
  • 3
  • 28
  • 42
  • there is a lot of files but if I encrypt them I have to decrypt a file and store it on disk every time I need to open the file right? then the user can access it while my program is using it – Lance Jan 16 '15 at 11:13
  • Yes that's right, users could still access encrypted file via Explorer, but wouldn't be able to open the files directly. With Embedded Resources or using a Resource file, the files are compiled into the dll / exe, so the user cannot get hold of them directly. The solution @dymanoid proposes is a good one to consider as well. But it still means users can access the zipped file directly. If you don't mind that, then it's probably a good bet. – Niels Filter Jan 19 '15 at 07:34
0

Managed to do it by converting all files to shock wave flash files and encrypting them. Then I could decrypt the files into a memory stream and display straight into a flash player.

Lance
  • 19
  • 5