1. 程式人生 > >mono for android Json 上傳檔案

mono for android Json 上傳檔案

    void button_Click(object sender, EventArgs e)
        {
            string Url = "上傳地址,伺服器端負責接收";

            byte[] fbytes;
            int Id = 1;
            string filename = "text.jpg";
            string emsg = "";
            System.Json.JsonObject id = new System.Json.JsonObject()
            { 
                //{"fBytes","二進位制資料"},{"MemberID","會員ID"},{"fileName","檔名"},{"eMsg",""}
                {"fBytes",fbytes.ToString()},{"MemberID",Id},{"fileName",filename},{"eMsg",emsg}
            };

            string up = id.ToString();

            try
            {
                HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest;
                request.ContentLength = up.Length;
                request.Method = "POST";
                request.ContentType = "application/json";
                StreamWriter stOut = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.Default);
                stOut.Write(up);
                stOut.Close();
                //request.BeginGetResponse(new AsyncCallback(ProcessRestJSONLINQHttpResponse), request);
            }
            catch (Exception)
            {

                throw;
            }


        }

 以前的我是沒有做筆記的習慣的,學習了後覺得自己能記住,但是最近發現很多學的東西都忘記了,所有現在一有新的知識,就記下來吧。

 最近又做一個mono for android 的專案 這次調整比較大,上次做的點餐系統很好用 ,但是做的時候沒有做筆記很多東西都忘記了,這次我把專案涉及到的知識傳到部落格上,方便記憶,也很大家分享分享的,希望大家能給出點意見。——小査