Buenas:
Ya lo he conseguido. Dejo el código por si alguien lo necesita o le pica la curiosidad.
Código C#:
Código:
using System;
using System.Threading;
namespace Barra_progreso_consola_03_cs
{
class Program
{
// Variable.
static double resultadoPorcentaje;
static void Main(string[] args)
{
Console.Title = "Simulador barra de progreso";
Console.WindowWidth = 60; // X ancho.
Console.WindowHeight = 10; // Y altura.
Console.CursorVisible = false;
// Variable.
int barra = 58;
int porcentaje = 0;
// Dibujamos la barra del portentaje.
Console.SetCursorPosition(0, 3);
Console.Write("0 % 50 % 100 %");
Console.SetCursorPosition(0, 4);
Console.Write("┌────────────────────────────┬───────────────────────────┐");
Console.SetCursorPosition(0, 5);
Console.Write("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); // Ascii 176.
Console.SetCursorPosition(0, 5);
Console.ForegroundColor = ConsoleColor.Yellow;
for (int i = 0; i < barra; i++)
{
resultadoPorcentaje = (i + 1.0D) / (barra / 100.0);
Console.Write("█"); // Muestra ASCII 219 Dec y DB en Hex.
// Console.Write((char)219);
// Console.Write(Encoding.ASCII.GetBytes((char)219));
porcentaje++; // Incrementa valor.
PintarCargando(porcentaje);
Thread.Sleep(300); // 100 ms o 0.1 segundos.
}
// Pulse cualquier tecla para salir.
Console.ReadKey();
}
static void PintarCargando(int porcentaje)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.SetCursorPosition(0, 1);
Console.Write("Cargado: " + (resultadoPorcentaje).ToString("N0") + " %");// por dos para que simule el 100%
// Reestablecemos para que vuelva a pintar bajo la línea de carga.
Console.ForegroundColor = ConsoleColor.Yellow;
Console.SetCursorPosition(porcentaje, 5);
}
}
}
Saluditos gente.