If you are a c# beginner or want to start learning the c# programming language, then this program will help you to understand the basics of c# programming. In this program, we are going to share Program to demonstrate the operations of C# path class.
Copy the below c# program and execute it in your Microsoft Visual Studio IDE (Integrated Development Environment ).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | using System; using System.IO; class Test { public static void Main() { string p = @"c:\srip\sri.txt"; string p2 = @"c:\srip\sri"; string p3 = @"srip"; if (Path.HasExtension(p)) { Console.WriteLine("{0} has an extension.", p); } if (!Path.HasExtension(p2)) { Console.WriteLine("{0} has no extension.", p2); } if (!Path.IsPathRooted(p3)) { Console.WriteLine("The string {0} contains no root information.", p3); } Console.WriteLine("Location for Temporary Files : {0}", Path.GetTempPath()); Console.WriteLine("Full path of {0} is {1}.", p3, Path.GetFullPath(p3)); Console.WriteLine("File available for Use : {0} ", Path.GetTempFileName()); Console.Read(); } } |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.