How to get a list of invalid filename characters into a dictionary with C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var dic = new Dictionary<char, bool>();

            dic = Path.GetInvalidFileNameChars().ToDictionary(c => c, c => true);

            foreach (KeyValuePair<char, bool> pair in dic) {
                Console.WriteLine("{0} : {1}", pair.Key, pair.Value);
            }
        }
    }
}


/*
run:
  
" : True
< : True
> : True
| : True
☺ : True
☻ : True
♥ : True
♦ : True
♣ : True
♠ : True
 : True
         : True
♂ : True
♀ : True
♫ : True
☼ : True
► : True
◄ : True
↕ : True
‼ : True
¶ : True
§ : True
▬ : True
↨ : True
↑ : True
↓ : True
→ : True
← : True
∟ : True
↔ : True
▲ : True
▼ : True
: : True
* : True
? : True
\ : True
/ : True

*/

 



answered Aug 17, 2018 by avibootz

Related questions

1 answer 170 views
1 answer 194 views
1 answer 103 views
103 views asked Aug 7, 2023 by avibootz
1 answer 232 views
2 answers 267 views
...