0

I'm developing an electron application and when the user first starts the program, a random string is generated. This needs to then be persisted across sessions. This string is extremely important and cannot be lost.

I've been trying to think of both how to store this and the best place and method to store this string.

Here are some potential solutions I came up with:

  1. Embed the string into the executable of the program.

    • I don't know if this can be done after the program is already installed. Also if the user uninstalls the program it will be lost.
  2. Store the string in a text file into the installation directory of the program.

    • Decent, but a similar concern with the first option. While an uninstall process may be able to skip that file, I worry that a user might delete the directory afterwards and lose the file.
  3. Store it in the OS-specific app-data folder.

    • Probably the best thing I've considered so far.
  4. Store it in the registry

    • Not sure the support for this sort of operation cross-platform.

In addition to a lot of these, I was wondering about additional precautions I could take, but was unsure of the viability of them. Such as:

  1. A combination of the above? Perhaps store it in multiple locations so that if the user accidentally deletes it from one, there is a backup?

  2. Is it possible to make the file difficult to delete? That is, a cross-platform way to assign a file permissions such that it requires escalation to delete it so that the user doesn't accidentally delete it.

Is there anything else that can be done that I might be missing? Storing it online cannot be done.

  • Tell the user to watch out for that file and let him decide where to store it. If he deletes it ... well he probably is going to have a problem. On the other hand why would assume its a unconscious decision to delete it? – Seth Jan 26 '18 at 7:29
0

Just a suggestion: Do option 3, seems the most sensible to me, and in addition tell the user to make a backup of that file and choose a backup location.

If the file in the app-data folder is lost or damaged for some reason, ask the user for the backup copy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.