If you want to determine if a string contains a relative or absolute folder / file path, you can use the System.IO.Path.IsPathRooted function:

Console.WriteLine(System.IO.Path.IsPathRooted(@"..\Test.cs")); // Result: False
Console.WriteLine(System.IO.Path.IsPathRooted(@"C:\Test.cs")); // Result: True

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.