Path.GetDirectoryName returns "null" in build

Hey guys,
I´m trying to get the name of a Directory to be stored in a string called “pathtemp”, below is the relevant part of my code. This works like a charm in the editor, no problems there. But in a standalone build - the same code returns null. Does anyone have an idea about what is going wrong?

 FileInfo[] info;
 DirectoryInfo di = new DirectoryInfo (Application.dataPath);
  info = di.GetFiles ("*.*");
        
        		foreach (FileInfo filename in info) {
        			
        			string filename_string;
        			filename_string = filename.ToString ();
        			pathtemp = Path.GetDirectoryName (filename_string);
        }

All the pathing stuff is a lot less smart than you would want it to be. Try getting the absolute path (with Path.GetFullPath), first, then getting the directory name off the absolute path.