Current Path
In this chapter you will learn:
Get Application Path
using System;/* j a va2 s . c om*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Utility
{
public static string GetApplicationPath()
{
string startupFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
int lastIndex = startupFile.LastIndexOf('\\');
startupFile = startupFile.Substring(0, lastIndex);
return startupFile;
}
}
Get current path
using System;//from j av a 2s .c om
using System.IO;
static class MainClass
{
static void Main()
{
Console.WriteLine("Using: " + Directory.GetCurrentDirectory());
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- List directory under a directory
- List files under a directory
- All Directories traverses all sub-directories under the root
- Get file list
Home » C# Tutorial » File, Path