//Form程序 private static String getExeFileFolder() { String strExeFolder = System.Reflection.Assembly.GetExecutingAssembly().Location; int nPos = strExeFolder.LastIndexOf("\\"); if (nPos >= 0) { strExeFolder = strExeFolder.Substring(0, nPos + 1); } else { strExeFolder = strExeFolder + "\\"; } return strExeFolder; } //IIS程序 String rootPath = Request.PhysicalApplicationPath; String strExeFolder = getExeFileFolder(rootPath); private static String getExeFileFolder(String strExeFolder) { int nPos = strExeFolder.LastIndexOf("\\"); if (nPos >= 0) { strExeFolder = strExeFolder.Substring(0, nPos + 1); } else { strExeFolder = strExeFolder + "\\"; } return strExeFolder; }