You can use GetDirectoryName, to get only the directory path of the file:
using System.IO;
string directoryName = Path.GetDirectoryName(@"C:\myfolder\subfolder\mydoc.pdf");
// directoryName now contains "C:\myfolder\subfolder"
For calculating the directory and subdirectory size, you can do something like this:
public static long DirSize(DirectoryInfo d)
{
long Size = 0;
// Add file sizes.
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
Size += fi.Length;
}
// Add subdirectory sizes.
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
Size += DirSize(di);
}
return(Size);
}