louyaoluan 发表于 2015-5-30 08:55:27

部分FTP类代码

  using System;
using System.IO;
using System.Configuration;
  namespace 4ec
{
    ///
    /// 部分FTP类代码
    ///
    public class FTP
    {
      public FTP()
      {
  }
      public static string getParentDirectory()
      {
            System.Web.HttpContext context = System.Web.HttpContext.Current;
            string path = context.Session["Path"].ToString();
            if (path == "./")
                return ("../");
            else if (path == "/")
                return (ConfigurationSettings.AppSettings["rootPath"].ToString());
            else
            {
                if (path.LastIndexOf("/") == path.Length - 1)
                {
                  path = path.Remove(path.LastIndexOf("/"), (path.Length - path.LastIndexOf("/")));
                }
                try
                {
                  
                  //path = path.Remove(path.LastIndexOf("/"), (path.Length - path.LastIndexOf("/")));
                  return (path + "/");
                }
                catch
                {
                  return (ConfigurationSettings.AppSettings["rootPath"]); // default to root;
                }
            }
  }
  public static void ReportError(string problem, string tech, string suggestion)
      {            
            System.Web.HttpContext context = System.Web.HttpContext.Current;
            string output = "Problem: " + problem + "";
            output += "Suggestion: " + suggestion + "";
            output += "Technical details: " + tech + "";
            context.Response.Write(output);
      }
    }
}
页: [1]
查看完整版本: 部分FTP类代码