private FileSystemInfo getMostRecentlyUpdatedIniFile()
        {
            DirectoryInfo DirInfo = new DirectoryInfo(
                Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                    "Electronic Arts",
                    "Dark Age of Camelot",
                    "phoenix"));

            if (!DirInfo.Exists)
            {
                DirInfo = new DirectoryInfo(
                    Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                        "Electronic Arts",
                        "Dark Age of Camelot",
                        "LoTM"));
            }
            return(DirInfo.Exists
                ? DirInfo.GetFileSystemInfos("*.ini").OrderByDescending(fi => fi.LastWriteTime).First()
                : null);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DirectoryInfo DirInfo = new DirectoryInfo(@"C:\");
            int           cursor  = 0;
            int           n       = DirInfo.GetFileSystemInfos().Length;

            ShowDir(DirInfo, cursor);

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                if (key.Key == ConsoleKey.DownArrow)
                {
                    cursor++;
                    if (cursor == n)
                    {
                        cursor = 0;
                    }
                }

                if (key.Key == ConsoleKey.UpArrow)
                {
                    cursor--;
                    if (cursor == -1)
                    {
                        cursor = n - 1;
                    }
                }

                if (key.Key == ConsoleKey.Enter)
                {
                    if (DirInfo.GetFileSystemInfos()[cursor].GetType() == typeof(DirectoryInfo))
                    {
                        DirInfo = new DirectoryInfo(DirInfo.GetFileSystemInfos()[cursor].FullName);
                        cursor  = 0;
                        n       = DirInfo.GetFileSystemInfos().Length;
                    }

                    else
                    {
                        StreamReader sr = new StreamReader(DirInfo.GetFileSystemInfos()[cursor].FullName);
                        string       s  = sr.ReadToEnd();
                        Console.Clear();
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(s);
                        Console.ReadKey();
                    }
                }

                if (key.Key == ConsoleKey.Escape || key.Key == ConsoleKey.Backspace)
                {
                    if (DirInfo.Parent != null)
                    {
                        DirInfo = DirInfo.Parent;
                        cursor  = 0;
                        n       = DirInfo.GetFileSystemInfos().Length;
                    }
                    else
                    {
                        break;
                    }
                }

                ShowDir(DirInfo, cursor);
            }
        }