Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1.       [Serializable()]
  2.       public class Logon
  3.       {
  4.  
  5.          public string user { get; set; }
  6.          public TimeSpan time { get; set; }
  7.          public DateTime date { get; set; }
  8.          public string IPAdress { get; set; }
  9.          public string ComputerName { get; set; }
  10.          public string Login { get; set; }
  11.         public RecordSerializable()
  12.                : this( 0, string.Empty, string.Empty, 0M )
  13.          public RecordSerializable( string IPAdress, string ComputerName, string user, string Login )
  14.          {
  15.             IPAdress = "IPADRESS" + GetLocalIPAdress();
  16.             ComputerName = System.Environment.MachineName;
  17.             FormLock testBox = new FormLock();
  18.             user = testBox.textBox1.Text;
  19.             Login = "False";
  20.          }
  21.          public static string GetLocalIPAdress()
  22.          {
  23.             var host = Dns.GetHostEntry(Dns.GetHostName());
  24.             foreach (var ip in host.AddressList)
  25.             {
  26.                if (ip.AddressFamily == AddressFamily.InterNetwork)
  27.                {
  28.                   return ip.ToString();
  29.                }
  30.             }
  31.             throw new Exception("Local IP Address Not Found!");
  32.  
  33.  
  34.          }
  35.          private BinaryFormatter formatter = new BinaryFormatter();
  36.        
  37.          
  38.             private FileStream output; // stream for writing to a file
  39.          
  40.          private void serializeThis()
  41.          {
  42.            
  43.  
  44.             List<Logon> values = new List<Logon>();
  45.             string fileName = "loginfo.dat";
  46.             try
  47.             {
  48.                output = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
  49.             }
  50.             catch (IOException)
  51.             {
  52.                MessageBox.Show("Error opening file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  53.             }
  54.             RecordSerializable record = new RecordSerializable();
  55.          }
  56.        
  57.  
  58.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement