This is a C# Program to demonstrate the operations of C# path class.
This C# Program Demonstrates the Operations of C# Path Class.
Here a path is a string that provides the location of a file or directory. A path does not necessarily point to a location on disk.
Here is source code of the C# Program to Demonstrate the Operations of C# Path Class. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Demonstrate the Operations of C# Path Class */ 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(); } }
This C# program is used to demonstrate the operations of c# path class. If condition statement is used to check the value in IsPathRooted() function is not equal to the argument value. The IsPathRooted() function is used to get a value indicating whether the specified path string contains a root.
If the condition is true then execute the iteration of the statement. The path is a string that provides the location of a file or directory. A path does not necessarily point to a location on disk.
c:\srip\sri.txt has an extension. c:\srip\sri has no extension. The string srip contains no root information. Location For Temporary Files : C:\Users\Win7\appdata\local\temp\ Full Path of Temp : D:\sri\ConsoleApplication22\ConsoleApplication22\bin\Debug\srip. File Available for Use : C:\Users\Win7\appdata\local\temp\trmpEB1B.tmp
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Check MCA Books
- Check C# Books
- Check Computer Science Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship