Current Path

In this chapter you will learn:

  1. Get Application Path
  2. Get current path

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:

  1. List directory under a directory
  2. List files under a directory
  3. All Directories traverses all sub-directories under the root
  4. Get file list
Home » C# Tutorial » File, Path
File creation
Deleting Files
Put to recycle bin
File Exists
File moving
File size
File attribute
Set file attribute
File time change
File time
Random file name
Temporary file
Path
Directory creation
Delete directory
Path existance
Change the path
Current Path
Directory listing
Recursive Path Listing
Combine path
Calculate Directory Size
Invalid path characters
System path
Directory copy
Drive
Drive information
File access rule
File System watcher