try 

     // 得到程序集位置 
      string path = System.IO.Path.GetDirectoryName(GetType().Assembly.Location); 
     // 得到文件位置 
      if (File.Exists(System.IO.Path.Combine(path, "数据库联接脚本.txt"))) 
     { 
         MessageBox.Show(" 加载 数据库联接脚本 成功!" + "\r\n" + "文件位置:" + "\r\n" + 
                                    System.IO.Path.Combine(path, " 数据库联接脚本.txt")); 
     } 
     else 
     { 
         MessageBox.Show(" 加载 数据库联接脚本 失败!"); 
     } 

catch(Exception ex) 

     Debug.WriteLine("XBAPPro.Page1.PageLoad Exception: " + ex.Message); 
     MessageBox.Show(" 加载 数据库联接脚本 异常!" + "\r\n" + ex.Message); 
} 我这里的文件名称叫做"数据库联接脚本.txt"