Hi again to All,
How it would be possible to save some Datas (strings and int) to a *.txt file ?
I have found some informations but the examples are all about saving text in a textbox (multiline) to a txt file.
I will need to write some strings/int which are allready decleared to a file.
thanx again

Sukesh MarlaPosted Aug 23, 2012, 1:25 AM
string[] lines = {"First line", "Second line", "Third line"};
System.IO.File.WriteAllLines(@"C:\Users\Public\TestFolder\WriteLines.txt", lines);
// Example #2: Write one string to a text file.
string text = "A class is the most powerful data type in C#. Like structures, " +
"a class defines the data and behavior of the data type. ";
System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", text);
// Example #3: Write only some strings in an array to a file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\TestFolder\WriteLines2.txt"))
{
foreach (string line in lines)
{
if (line.Contains("Second") == false)
{
file.WriteLine(line);
}
}
}
// Example #4: Append new text to an existing file
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\TestFolder\WriteLines2.txt", true))
{
file.WriteLine("Fourth line");
}
}
Check this is corerct answer if it helped
Sukesh MarlaPosted Aug 23, 2012, 12:54 PM
ilhami caliskanPosted Aug 23, 2012, 11:41 AM
Jignesh TrivediPosted Aug 22, 2012, 11:32 PM
Please refer...
http://msdn.microsoft.com/en-us/library/8bh11f1k.aspx
http://msdn.microsoft.com/en-us/library/aa287548%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/system.io.file.appendtext.aspx
hope this will help you.
Javeed M ShaikhPosted Aug 22, 2012, 1:09 PM
#1:
#2:
#3: