none
Language problem in console - C# RRS feed

  • Question

  • Hello,

    In the below output we have some file with Persian or arabic name and show ?????  in console.

    How can solve this problem?

    Thanks

    using System;
    using System.IO;
    using System.Linq;
    
    namespace ConsoleApp11
    {
        class Info
        {
            public long Length { get; set; }
            public string Name { get; set; }
            public DateTime FileDateTime { get; set; }
        }
        class Program
        {
            static void Main(string[] args)
            {
                FileInfo[] file = new DirectoryInfo("D:\\d").GetFiles();
    
                var query = from item in file
                            where item.Length > 1000
                            orderby item.Length, item.Name
                            select new Info
                            {
                                Name = item.Name,
                                Length = item.Length,
                                FileDateTime = item.CreationTime
                                
                            };
    
                foreach (var item in query)
                {
                    Console.WriteLine($"{item.Name} - {item.Length} - {item.FileDateTime}");
                }
                Console.Read();
            }
        }
    }
    

    Tuesday, April 3, 2018 9:52 PM

All replies