What characters are forbidden in Windows and Linux directory names?

前端 未结 17 2633
北海茫月
北海茫月 2020-11-22 01:05

I know that / is illegal in Linux, and the following are illegal in Windows (I think) * . \" / \\ [

17条回答
  •  太阳男子
    2020-11-22 02:02

    For Windows you can check it using PowerShell

    $PathInvalidChars = [System.IO.Path]::GetInvalidPathChars() #36 chars
    

    To display UTF-8 codes you can convert

    $enc = [system.Text.Encoding]::UTF8
    $PathInvalidChars | foreach { $enc.GetBytes($_) }
    
    $FileNameInvalidChars = [System.IO.Path]::GetInvalidFileNameChars() #41 chars
    
    $FileOnlyInvalidChars = @(':', '*', '?', '\', '/') #5 chars - as a difference
    

提交回复
热议问题