i am creating program that checks if the path is valid or not

Depending on your needs, it could be as simple as:

if (Directory.Exists(path) || File.Exists(path))
{
    // Yuppers
}

But it's somewhat hard to answer your question because it's a little vague. What exactly constitutes "valid", for example? What kind of paths are you supporting? Is this a file path or a folder path, or could it be either?

if the path is valid or not

With Regex you could test if a pathstring is valid or not.
I'm certain there are many examples of this to be found on the web.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.