Good afternoon, I have such a question, where and how to properly store files in a WPF application, but so that access to the files was only programmatically, from outside that it was impossible to reach the directory?

  • Write in more detail what files you need to store. And what do you mean by "from outside that it would be impossible to reach the directory". As an option to make files hidden / serialize / encrypt individually or all together - Artemiy Borodin
  • Give access to files only a specific account. To work with the data from the files through a special service that works under that particular account. In the simplest case, files can be opened on behalf of this account. I do not know the truth, but there must be a way. - Sergey
  • I'm trying to hide audio files from users - Samat Yeshernkulov
  • If the files are on the user's machine, he will, if he wants, get access to them. - VladD
  • Even in .net there is such a thing msdn.microsoft.com/ru-ru/library/3ak841sy (v=vs.110).aspx . I have never used it myself and do not know how it physically stores. - vitidev

2 answers 2

I can assume that the author needs to hide the files used by the program from the user. Known solutions to me:

  1. Encrypt. But this does not protect against deletion.
  2. Add file to application resources. (the most suitable option if the files are not large in size)
  • 3. Store in C: \ Users \ User \ AppData \ Local \ AppName - Artemiy Borodin
  • @ArtemiyBorodin as an option, if you need a "protection against a fool." Access to this folder is not restricted to the user. - Alexey
  • it is hidden by default, so at least some kind of protection, we have in one project * .dll throw in C: \ Windows \ SysWOW64 \ just the same with the aim of hiding it - Artemiy Borodin
  • I apologize and what kind of channels, you can detail? - Samat Yeshernkulov
  • And another question is how to hide files? for example, this code hides the files DirectoryInfo di = Directory.CreateDirectory(path); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; DirectoryInfo di = Directory.CreateDirectory(path); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; but it cannot completely hide the file, when transferring the program to a flash drive for example, and if you run the program from there, the file appears as visible - Samat Yeshernkulov

Hide data in stream (File streams). In Windows, you can attach streams to the file, even the presence of which cannot be seen by conventional means (explorer). Create a stream on the program exe-file. FIG who will guess.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx

The truth is not clear how to distribute such a program. Stream probably and not copied by conventional means?

For audio and for other static data the place is in the resources, as someone has already answered. Resources are located directly in the program file (or library).