here's a rough one I used to get me out of trouble in the past ... just for reference
//get the current drgs' containing folder:
string folderpath = doc.Name;
int lastslash = folderpath.LastIndexOf("\\") + 1;
folderpath = folderpath.Remove(lastslash,folderpath.Length - lastslash);