Yuki Kutsuya
Yuki Kutsuya

Reputation: 4088

Editting a string in resources

how would I edit a string in the resources of my project? I get this error when I try it:

Property or indexer 'Project.Properties.Resources.ExternalIp' cannot be assigned to -- it is read only

This is what I do:

Resources.ExternalIp = utf8.GetString(webClient.DownloadData("http://automation.whatismyip.com/n09230945.asp"));

Upvotes: 0

Views: 2907

Answers (2)

S3ddi9
S3ddi9

Reputation: 2151

Properties.Ressources are readonly ("compiled"), you have to use Properties.Settings & put the Scope to "User" so it will be 'ReadWrite'

Project.Properties.Settings.Default.ExternalIp = utf8.GetString(webClient.DownloadData("http://automation.whatismyip.com/n09230945.asp"));
Project.Properties.Settings.Default.Save();

enter image description here

Upvotes: 5

Thomas Levesque
Thomas Levesque

Reputation: 292465

Resources are not supposed to be written to; they're embedded in the executable, so changing them would involve modifying the executable.

From your code, it looks like you actually need application settings, not resources.

Upvotes: 4

Related Questions