Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Serializable()]
- public class Logon
- {
- public string user { get; set; }
- public TimeSpan time { get; set; }
- public DateTime date { get; set; }
- public string IPAdress { get; set; }
- public string ComputerName { get; set; }
- public string Login { get; set; }
- public RecordSerializable()
- : this( 0, string.Empty, string.Empty, 0M )
- public RecordSerializable( string IPAdress, string ComputerName, string user, string Login )
- {
- IPAdress = "IPADRESS" + GetLocalIPAdress();
- ComputerName = System.Environment.MachineName;
- FormLock testBox = new FormLock();
- user = testBox.textBox1.Text;
- Login = "False";
- }
- public static string GetLocalIPAdress()
- {
- var host = Dns.GetHostEntry(Dns.GetHostName());
- foreach (var ip in host.AddressList)
- {
- if (ip.AddressFamily == AddressFamily.InterNetwork)
- {
- return ip.ToString();
- }
- }
- throw new Exception("Local IP Address Not Found!");
- }
- private BinaryFormatter formatter = new BinaryFormatter();
- private FileStream output; // stream for writing to a file
- private void serializeThis()
- {
- List<Logon> values = new List<Logon>();
- string fileName = "loginfo.dat";
- try
- {
- output = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
- }
- catch (IOException)
- {
- MessageBox.Show("Error opening file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- RecordSerializable record = new RecordSerializable();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement