Beispiel #1
0
        public static bool IsURLExist(string url)
        {
            bool valid = false;

            try
            {
                WebRequest req = WebRequest.Create(url);
                using (WebResponse res = req.GetResponse()) { }
                valid = true;
            }
            catch (WebException ex)
            {
                Console.Write(" =====> "); CColor.WriteLineC(" ### " + ex.Message, "red");
            }
            return(valid);
        }
Beispiel #2
0
 public static void DoAGetRequest(string link, string nFileFix)
 {
     // Construct HTTP request to get the file
     Console.Write("--- Dowloading: "); CColor.WriteLineC(Program.FixStringChar(link.Split('/').Last()), "yellow");
     using (WebClient client = new WebClient())
     {
         try
         {
             // Specify that the DownloadFileCallback method gets called
             // Specify a progress notification handler.
             client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
             // when the download completes.
             //client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback);
             client.DownloadFileAsync(new Uri(link), nFileFix);
         }
         catch (Exception ex) { Program.pL.Percent = -1; CColor.WriteLineC(" ### Error # \r\n" + ex.Message, "red"); }
     }
 }
Beispiel #3
0
 public void SincePrintProgress()
 {
     Console.CursorVisible = false;
     Console.Write(" =====> ");
     while (Percent <= stepProgress)
     {
         if (stepProgress == Percent)
         {
             stepProgress = 99;
         }
         // Generate new state
         int width = (int)(Percent / 100 * barLength);
         int fill  = barLength - width;
         //Delete Last String
         string clear = string.Empty.PadRight(LastOutputLength, '\b');
         Console.Write(clear);
         Console.Write((Percent < 10 ? "  " : (Percent >= 10 && Percent < 100) ? " " : "") + "{0:0.0}% [ ", Percent); CColor.WriteC(string.Empty.PadLeft(width, '█'), "green"); Console.Write("{0} ] - ", string.Empty.PadLeft(fill, ' '));
         LastOutputLength = 5 + "% [ ".Length + barLength + " ] - ".Length;
     }
     CColor.WriteC(" DONE", "green"); Console.WriteLine('!');
     Console.CursorVisible = true;
 }
Beispiel #4
0
        public void UpdatePrintProgress(double PercentUp)
        {
            Console.CursorVisible = false;
            // Generate new state
            int width = (int)(PercentUp / 100 * barLength);
            int fill  = barLength - width;
            //Delete Last String
            string clear = string.Empty.PadRight(LastOutputLength, '\b');

            Console.Write(clear);
            if (true)
            {
                Console.Write((Percent < 10 ? "  " : (PercentUp >= 10 && PercentUp < 100) ? " " : "") + "{0:0}% [ ", PercentUp); CColor.WriteC(string.Empty.PadLeft(width, '█'), "green"); Console.Write("{0} ] - ", string.Empty.PadLeft(fill, ' '));
                LastOutputLength = 3 + "% [ ".Length + barLength + " ] - ".Length;
            }
        }
Beispiel #5
0
 private static void DownloadFileCallback(object sender, AsyncCompletedEventArgs e)
 {
     CColor.WriteC(" DONE", "green"); Console.WriteLine("!");
 }