0

I am new in vb.net, and someone used 'My.Settings.*' on a vb.net program I inherited.

I would like to know where the data are stored when using My.Settings in vb.net

If I have a member variable called IpAddress for example, can I have an other class using its own member variable called IpAddress without being confusing for the program ?

What if an other program is runing using a variable called IpAddress, can those be mixed up ?

  • 2
    You're asking two completely unrelated questions there. Please post each question in a separate thread with a title that describes that specific question. – jmcilhinney Jul 03 '18 at 15:14
  • Application-scoped settings are read-only and are stored in the application config file, in the same folder as the executable. User-scoped settings are read-write and have their default values stored in the application config file too. The current values of User-scoped settings are stored in a user config file under each user's personal folder. – jmcilhinney Jul 03 '18 at 15:16
  • Well the question is about the way those data are stored. Are they stored under "MyVariable" or "class.MyVariable", and are they locally stored or in a shared place ? – j.DoeTheFifth Jul 03 '18 at 15:17
  • @jmcilhinney : Thank you ! – j.DoeTheFifth Jul 03 '18 at 15:18
  • Variables cannot be "confused" unless they are declared with the same name in the same place. If two member variables are declared with the same name in two different types then they don't have the same name, because they are qualified with different types, e.g. `Class1.SomeField` and `Class2.SomeField`. If the compiler can't determine which one you're referring to based on the unqualified name then you will be required to use the qualified name. As for local variables, one declared at any scope automatically hides one declared with the same name at a more outer scope. – jmcilhinney Jul 03 '18 at 15:20
  • @jmcilhinney : perfect! Thank you – j.DoeTheFifth Jul 03 '18 at 15:24
  • Application settings are application-specific. Two different application's settings cannot get mixed up with each other because the settings files are stored in locations which include a hash of the application path and some of the .exe information. See this for more info: https://stackoverflow.com/a/8691876 (`C:\Documents and Settings\USERNAME\LocalSettings` is nowadays `%UserProfile%\AppData\Local`). – Visual Vincent Jul 03 '18 at 16:24

1 Answers1

0

My.Setting are stored in user/AppData/Local

You can have variables with same name in different scopes. Even though they appear to have the same name to you, they do not to the code.

CruleD
  • 1,153
  • 2
  • 7
  • 15