简体   繁体   中英

How can I save the textbox content to the application itself?

Simply put, for example, I want to save content of a textbox to the application itself.

I tried "My.Settings" but type of settings must be "user-scoped" & settings(string content of textbox) extracting to %appdata% folder(user.config).

I want store the data(confidential text) on the application without extracting it to anywhere.

On the other hand "application-scoped" settings are "Read-Only" and values of settings can not be change while type of settings "application-scoped". I want settings(string content of textbox) always changeable by the user of app.

TextFile in Resources is also read-only...I have to extract TextFile for changing the content of TextFile.

How can i do that?

You can use My.Computer.Filesystem.WriteAllText() & My.Computer.Filesystem.ReadAllText() to write/read files. And there's no better way.

But yeah, you can achieve your requirement by saving the data into Registry, ie if you want to save your any text data which is accessible anywhere from the device, it could really be helpful.

Note that your application will require to be ran as administrator for saving/reading registry values.

To save registry value:

My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\something", "ValueName", "Value")

To access it:

My.Computer.Registry.GetValue("Same Location", "Same ValueName", Nothing) ' Note that "Nothing" is returned when value doesn't exists.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM