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?


    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}");

    Tuesday, April 3, 2018 9:52 PM

All replies

  • https://msdn.microsoft.com/en-us/library/system.console.outputencoding(v=vs.110).aspx

    Before somebody thinks ASCII is the standard. That is often wrong used, ASCII is a 7 channel papertape code and nowhere in use anymore. 


    Tuesday, April 3, 2018 10:17 PM
  • I change encoding to UTF-8 and change font to 'Courier New' but The letters are separated :(

    How can solve it?

    • Edited by Arash_89 Tuesday, April 3, 2018 10:58 PM
    Tuesday, April 3, 2018 10:51 PM
  • Hi Arash_89,

    Try to set the system locate.

    Control Panel > Region and Language > Administrative > Change System locale

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 4, 2018 8:03 AM