A bit more info...once added the settings file, when you double click it, it will take you into the properties editor type screen, in here you define the settings/properties you want. Then in your code as shown simply access it via the settings class name and access your properties there. Once done, be sure you saved it via the Save() method in the settings class.
another way:
Dim theWriter as new System.IO.StreamWriter("file.txt")
theWriter.Write("hello!")
theWriter.Close()
the StreamWriter is a class in the .NET Framework in the System.IO namespace which allows you to write to a file or a stream of data as its basestream source. It allows you easily to write to the stream, as shown above.
To read it, we have a StreamReader class, does the same thing but in reverse - allows you to read from the stream by line or the entire file. To read a line:
Dim theReader as new System.IO.StreamReader("file.txt")
Dim singleLine as String = theReader.ReadLine()
theReader.Close()
this will read a single line from the file. To read the entire file:
Dim theReader as new System.IO.StreamReader("file.txt")
Dim entireFile as String = theReader.ReadToEnd()
theReader.Close()
be sure however the file to read does exist by using the System.IO.File.Exists() method, which will return true or false depending on if the file exists or not
save string at text file and retrieve the string it at vb.net
Danny Thorpe MSFT
you can do that indeed.
A bit more info...once added the settings file, when you double click it, it will take you into the properties editor type screen, in here you define the settings/properties you want. Then in your code as shown simply access it via the settings class name and access your properties there. Once done, be sure you saved it via the Save() method in the settings class.
another way:
Dim theWriter as new System.IO.StreamWriter("file.txt")
theWriter.Write("hello!")
theWriter.Close()
the StreamWriter is a class in the .NET Framework in the System.IO namespace which allows you to write to a file or a stream of data as its basestream source. It allows you easily to write to the stream, as shown above.
To read it, we have a StreamReader class, does the same thing but in reverse - allows you to read from the stream by line or the entire file. To read a line:
Dim theReader as new System.IO.StreamReader("file.txt")
Dim singleLine as String = theReader.ReadLine()
theReader.Close()
this will read a single line from the file. To read the entire file:
Dim theReader as new System.IO.StreamReader("file.txt")
Dim entireFile as String = theReader.ReadToEnd()
theReader.Close()
be sure however the file to read does exist by using the System.IO.File.Exists() method, which will return true or false depending on if the file exists or not
Takashi Toyota
What
I guess you want to persist a String setting.
Go to My Project -> Settings and add a setting.
Then in your code:
My.Settings.MyString=MyString
My.Settings.Save
Then in the Form_Load method:
MyString=My.Settings.MyString
Oliver 123
Walt C.
rss0213
ahmedilyas,
Sorry if this request sounds needy and feeble, but
Please can you mark my post as answer Its just I keep providing answers to people and they don't actually acknowledge this.