private string DecodeBase64(string code, string charset) //charset 为邮件内容字符集,空则默认为utf-8
    {
        if (encode == "")
        {
            encode = "utf-8";
        }
        string decode = "";
        string st = code + "000"; //
        string strcode = st.Substring(0, (st.Length / 4) * 4);
        byte[] bytes = Convert.FromBase64String(strcode);
        try
        {
            decode = System.Text.Encoding.GetEncoding(charset).GetString(bytes);
        }
        catch
        {
            decode = code;
        }
        return decode;
    }
posted on 2008-03-18 14:42  天歆  阅读(342)  评论(0编辑  收藏  举报