Ejemplo n.º 1
0
        public static int wiFiAsync()
        {
            FileStream      wifi      = new FileStream("wifi.json", FileMode.OpenOrCreate);
            BinaryFormatter formatter = new BinaryFormatter();


            if (wifi.Length == 0)
            {
                wifi.Close();
                return(0);
            }
            try
            {
                wifiReq        T       = (wifiReq)formatter.Deserialize(wifi);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.google.ru");
                request.Credentials = new NetworkCredential(T.name, T.password);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                wifi.Close();
                response.Close();
                return(1);
            }
            catch (Exception e)
            {
                wifi.Close();
                return(0);
            }
        }
Ejemplo n.º 2
0
        public static int CreateWifi(string Name, string Pas)
        {
            FileStream      wifi      = new FileStream("wifi.json", FileMode.OpenOrCreate);
            BinaryFormatter formatter = new BinaryFormatter();

            wifiReq T = new wifiReq();

            T.name     = Name;
            T.password = Pas;
            formatter.Serialize(wifi, T);
            wifi.Close();

            return(wiFiAsync());
        }