Пример #1
0
        /// <summary>
        /// 下载一个文件,返回描述符。
        /// </summary>
        /// <param name="sPath"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public static TFile DownloadFile(string sPath, FileTreeNode file)
        {
            string strFID = file.FileID;

            ClientAdapt.Open();
            TVssService.Client client = ClientAdapt.GetClient();
            TFile tFile = client.Get(GetValidator(), strFID);

            ClientAdapt.Close();
            File.WriteAllBytes(sPath, tFile.FileContent);

            return(tFile);
        }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["fileID"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        string fileID = Request["fileID"];



        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        try
        {
            ClientAdapt.Open();
            TVssService.Client client = ClientAdapt.GetClient();
            TFile file = client.Get(tValidator, fileID);
            ClientAdapt.Close();


            switch (file.FileKind)
            {
            case TContentKind.Weibo:
            {
                Response.ContentType = "text/html";
                Response.Write(System.Text.Encoding.UTF8.GetString(file.FileContent));
                break;
            }

            case TContentKind.Picture:
            {
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(file.FileContent);
                break;
            }

            default:
            {
                Response.ContentType = "text/html";
                Response.BinaryWrite(file.FileContent);
                break;
            }
            }
        }
        catch
        {
            ;
        }

        Response.End();
    }