just use this code
string fileFullName = @"G:\MailData\a\b\data.txt";
or string fileFullName = Server.MapPath("data.txt");
string pathWithoutFileName = System.IO.Path.GetDirectoryName(fileFullName);
it will return only path(without filename) G:\MailData\a\b or web root directory phisical path without filename.