我是 C# 的新手
我有这个代码
FileStream D = new FileStream("C:/PersonalAssistant/RecentMeetingDetails.txt", FileMode.Open, FileAccess.Read);
StreamReader DR = new StreamReader(D);
DR.BaseStream.Seek(0, SeekOrigin.Begin);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("ALERT! ALERT!! ALERT!!!");
Console.WriteLine("\nYour Closest Appointment is on " + rd + " and has the following info");
string data = DR.ReadLine();
while (data != null)
{
Console.WriteLine(data);
data = DR.ReadLine();
}
D.Close();
DR.Close();
我想要这个代码
Console.WriteLine("ALERT! ALERT!! ALERT!!!");
在从文件中读取其他详细信息并显示在屏幕上时闪烁
我试过这个
private static void WriteBlinkingText(string text, int delay)
{
bool visible = true;
while (true)
{
Console.Write("\r" + (visible ? text : new String(' ', text.Length)));
System.Threading.Thread.Sleep(delay);
visible = !visible;
}
}
并将 console.writeline 更改为
WriteBlinkingText("ALERT! ALERT!! ALERT!!!",500);
它有效,但未显示其他详细信息...
请帮助我更正此代码