Path
In this chapter you will learn:
Path operation
The static Path
class defines methods
and fields for working with paths and filenames.
using System;//from j a v a 2 s.co m
using System.IO;
using System.Linq;
using System.Text;
class Program
{
static void Main()
{
string dir = @"c:\g";
string file = "myfile.txt";
string path = @"c:\g\myfile.txt";
Directory.SetCurrentDirectory(@"k:\demo");
Directory.GetCurrentDirectory();
Path.IsPathRooted(file);
Path.IsPathRooted(path);
Path.GetPathRoot(path);
Path.GetDirectoryName(path);
Path.GetFileName(path);
Path.GetFullPath(file);
Path.Combine(dir, file);
Console.WriteLine(Path.GetTempFileName());
Console.WriteLine(Path.GetTempPath());
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » File, Path