コード例 #1
0
ファイル: frmMain.cs プロジェクト: DennisHeine/Timesheet
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (File.Exists(".\\data.dat"))
            {
                times = times.Load(".\\data.dat");
            }
            SetText(tbWiFi, times.WLANID, times.connectOnWLAN);
            WlanClient client = new WlanClient();

            while (true)
            {
                foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                {
                    // Lists all networks with WEP security
                    Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0);
                    foreach (Wlan.WlanAvailableNetwork network in networks)
                    {
                        String nam = network.profileName;
                        //if (nam == "wlan_lab_01")
                        if (nam == times.WLANID || rbProgramm.Checked)
                        {
                            times.addTimestamp();
                            times.Save(times, ".\\data.dat");
                        }
                    }
                }


                System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #2
0
        //Serializing the List
        public void Save(cTimes emps, String filename)
        {
            //Create the stream to add object into it.
            System.IO.Stream ms = File.OpenWrite(filename);
            //Format the object as Binary

            BinaryFormatter formatter = new BinaryFormatter();

            //It serialize the employee object
            formatter.Serialize(ms, emps);
            ms.Flush();
            ms.Close();
            ms.Dispose();
        }
コード例 #3
0
        public cTimes Load(String filename)
        {
            //Format the object as Binary
            BinaryFormatter formatter = new BinaryFormatter();

            //Reading the file from the server
            FileStream fs = File.Open(filename, FileMode.Open);

            object obj  = formatter.Deserialize(fs);
            cTimes emps = (cTimes)obj;

            fs.Flush();
            fs.Close();
            fs.Dispose();
            return(emps);
        }