Hello there, I have a code below, ... When you click on that BUTTON(the code button) I would like to be able to INSERT
TIME , DATE , and IP, into a TEXT file, into the next empty line, with out deleting what was inside of the text file, and then, upload that text file somewhere, .... I am going to give this software to about 14 people, and I would like to log each time they log in to it. Any other ideas? if not, how do I do this? ...
Thank you in advance for your help.
private void buttonLogin_Click(object sender, EventArgs e)
{
string password = textBoxPassword.Text;
if (SQLDataAccess.ValidateConnection("Account", password) == true)
{
SQLDataAccess.Password = password;
MessageBox.Show("Login Successful");
textBoxPassword.Text = "";
textBoxPassword.UseSystemPasswordChar = false;
FormCollection fc = Application.OpenForms;
foreach (Form ff in fc)
{
if (ff.Name == "Form1")
{
((Form1)(ff)).label1.Text = "Input Box";
}
}
}
else
{
MessageBox.Show("Login failed");
}
}
Loading

jingeRank #2,527 · 554 reputationPosted Sep 27, 2009, 2:05 AM EDT
jingeRank #2,527 · 554 reputationPosted Sep 26, 2009, 7:08 PM EDT
Roei BarRank #1,271 · 1.4K reputationPosted Sep 26, 2009, 10:35 PM EDT
private void file_append() { string path="D:\\Temp\\My Documents\\"; // Parent Directory string name=TextBox1.Text; string ext=".txt"; string fname=path+name+ext; FileInfo file1=new FileInfo(fname); StreamWriter sw=File.AppendText(file1) sw.WriteLine("This is a demo for appending text content to a file"); // Writing a string directly to the file sw.WriteLine(TextBox2.Text); // Writing content read from the textbox in the form sw.Close(); }Roei BarRank #1,271 · 1.4K reputationPosted Sep 26, 2009, 10:39 PM EDT
List textList = new List(); textList.AddRange(File.ReadAllLines(filepath); // Insert your new text here textList.Insert(0, newTextLine); // Write to file File.WriteAllLines(filepath, textList.ToArray());thiago costaRank #6,113 · 276 reputationPosted Sep 26, 2009, 11:40 PM EDT
Here is the code: static void Main(string[] args) { FileStream fs = new FileStream("log.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("append me"); sw.Close(); }
That method worked very well with my code =D Thank you Lots.
Thank you all !
thiago costaRank #6,113 · 276 reputationPosted Sep 27, 2009, 9:22 AM EDT
From now on I will not forget. I am so sorry.
And thank you once again.