using System;
using System.IO;
using System.Configuration;

namespace 4ec
{
    /// <summary>
    /// 部分FTP类代码
    /// </summary>
    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 = "<font color=red><BIG>Problem:</BIG> " + problem + "</font><hr>";
            output += "Suggestion: " + suggestion + "<hr>";
            output += "<small>Technical details: " + tech + "</small><hr>";
            context.Response.Write(output);
        }
    }
}

posted on 2007-04-05 21:40  E商.NET  阅读(208)  评论(0编辑  收藏  举报