Helpful Information
 
 
Category: .Net Development
Regarding C# Saving files into...

Please help me.

How can I ....

1) Transfer the values of the text box from the user interface to a text file

2) How can I Save that Text file into an *ini file


thanks in advance

yourTextBox.Text is a property which contains the value of yourTextBox.

about file access, refer to System.IO.File class

sir can you give me an example... thankx

// create a file stream, where "c:\\testing.txt" is the file path
System.IO.FileStream fs = new System.IO.FileStream("c:\\testing.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);

// create a stream writer
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.ASCII);

// write to file (buffer), where textbox1 is your text box
sw.Write(textbox1.Text);

// flush buffer (so the text really goes into the file)
sw.Flush();

// close stream writer and file
sw.Close();fs.Close();


short sample, hope it helps

// create a file stream, where "c:\\testing.txt" is the file path
System.IO.FileStream fs = new System.IO.FileStream("c:\\testing.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);

// create a stream writer
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.ASCII);

// write to file (buffer), where textbox1 is your text box
sw.Write(textbox1.Text);

// flush buffer (so the text really goes into the file)
sw.Flush();

// close stream writer and file
sw.Close();fs.Close();


short sample, hope it helps

Hi im pretty new to programing and im just leaning the ropes at the moment.
i used this code in an apliction and it works a treat.
could anyone tell me how to load the data that have been saved to the txt file

thanks in advance, james










privacy (GDPR)