Friday

C# csharp read from file write into file


public static string ReadFile(string f){
System.IO.StreamReader file = new System.IO.StreamReader(f);
string testxmldata = file.ReadToEnd(); file.Close();
return testxmldata;
}
public void WriteIntoFile(string path,string m) {
if (!File.Exists(path)) {
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path)) {
sw.WriteLine(m);
}
}
else {
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText(path)) {
sw.WriteLine(m);
}
}
}

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...