Question: I have a string that contains an exe full path and exe name like so:

```
mainExePath = "c:\Folder1\Folder2\MyProgram.exe"

```

I want to get jus the path like so:

```
"c:\Folder1\Folder2\"

```

I have tried this: 

```
string mainPath = System.IO.Path.GetFullPath(mainExePath);

```

but this returned the same string.

How can I do this?

Answer: 
Use `Path.GetDirectoryName(mainExePath)`
You could use the following one:

```
string mainPath = Directory.GetParent(mainExePath);

```

For further documentation on this, please haev a look [here](http://msdn.microsoft.com/en-us/library/system.io.directory.getparent%28v=vs.110%29.aspx).

**Update**

In order you use the `Directory` class, you have to use the `System.IO`. So please, on the sections of your source file, where you have placed the `using` statements for namespaces, please add also the below one:

```
using System.IO;

```