本文英文版:http://ceeji.net/en/blog/2010/03/csharp-how-to-get-the-executablepath-without-filename/

        /// <summary>
        /// 返回程序运行路径,带\
        /// </summary>
        /// <returns>程序运行路径,带\。</returns>
        public static string GetPath()
        {
            string str = System.Windows.Forms.Application.ExecutablePath;
            return str.Substring(0, str.LastIndexOf('\\') + 1);
        }
        /// <summary>
        /// 获得指定文件的路径,带\。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string GetPath(string str)
        {
            return str.Substring(0, str.LastIndexOf('\\') + 1);
        }