I want a Windows Form app to work only with a simple .exe, no folders or .txt files. So I was wondering if it's possible to when the app receives user input, to store it without creating excess files, but inside the code itself, so after the app is restarted, the user input is still there. Is there a way to do this?
Asked
Active
Viewed 116 times
0
-
3No, you cannot modify the file of the executable while it is running. You *will* have to find another place for the information. Registry, file, cloud save, etc. – Lasse V. Karlsen Jun 02 '19 at 14:33
-
Now, you *could* make a copy of the executable, from itself, when it is starting, and start the copy and then exit, so only the copy is running. The copy could then modify the original file. **However**, if your program is a well-behaved Windows program, it should be installed in a location where you're unable to modify the files unless an administrator anyway. – Lasse V. Karlsen Jun 02 '19 at 14:34
-
1[Settings](https://stackoverflow.com/questions/982354/where-are-the-properties-settings-default-stored) get hidden away; the average user won't know the "extra" file exists. – Idle_Mind Jun 02 '19 at 14:42
-
You could store the data in the registry. Not in the code itself but for the same user and machine it will work. BTW, Modifying the exec sounds like a bad idea since it might trigger anti virus warnings, or even the work folder might be read only. – Dr Phil Jun 02 '19 at 14:43
-
Are you trying to hide information? If so, in NTFS on Windows you have an excellent, slightly forgotten feature, alternate data streams; if your program is `a.exe`, then its ADS are `a.exe:[anything normally allowed for file names]`. They behave pretty much like normal files. You can write and read data to/from there. – the default. Jun 02 '19 at 15:00
1 Answers
1
You could save that content in the cloud using a web api. An additional benefit will be availability of that content to the user, independently of what machine the user is using your application.

Samuel Vidal
- 883
- 5
- 16