Invalid path characters

In this chapter you will learn:

  1. Get a list of invalid path characters

Invalid path characters

using System;/*from  ja v a2 s. c  o  m*/
using System.IO;

class GetCharExample
{
    public static void Main()
    {

        char[] invalidPathChars = Path.GetInvalidPathChars();

        Console.WriteLine("The following characters are invalid in a path:");
        ShowChars(invalidPathChars);
        Console.WriteLine();
    }

    public static void ShowChars(char[] charArray)
    {
        foreach (char someChar in charArray)
        {
                Console.WriteLine("{0:c},\t{1:X4}", someChar, (int)someChar);
        }
    }
}

Next chapter...

What you will learn in the next chapter:

  1. How to get system path
Home » C# Tutorial » File, Path
File creation
Deleting Files
Put to recycle bin
File Exists
File moving
File size
File attribute
Set file attribute
File time change
File time
Random file name
Temporary file
Path
Directory creation
Delete directory
Path existance
Change the path
Current Path
Directory listing
Recursive Path Listing
Combine path
Calculate Directory Size
Invalid path characters
System path
Directory copy
Drive
Drive information
File access rule
File System watcher