当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.ToString方法代码示例

本文整理汇总了C#中StreamReader.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.ToString方法的具体用法?C# StreamReader.ToString怎么用?C# StreamReader.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StreamReader的用法示例。


在下文中一共展示了StreamReader.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: runQuery

        public static string runQuery(string query, string acceptType)
        {
            Uri uri = new Uri(COOLADATA_ENDPOINT);
            HttpWebRequest webRequest;
            string result = String.Empty;
            try
            {
                webRequest = (HttpWebRequest)WebRequest.Create(uri);
                webRequest.Method = "POST";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Headers.Add("Authorization", COOALDATA_AUTHENTICATION_HEADER);
                webRequest.Accept = acceptType;

                var encodedQuery= Encoding.UTF8.GetBytes("tq=" + query);
                using (var stream = webRequest.GetRequestStream())
                {
                    stream.Write(encodedQuery, 0, encodedQuery.Length);
                }

                var response = (HttpWebResponse)webRequest.GetResponse();

                if ((int)response.StatusCode != 200)
                {
                    Console.WriteLine("Error! Status: " + response.StatusCode + " " + response.StatusDescription);
                    return null;
                }

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                return responseString.ToString();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
开发者ID:JaegerBane,项目名称:cooladata-query-api,代码行数:35,代码来源:QueryAPI.cs

示例2: AddNote

    public void AddNote()
    {
        try {

        var mynote=new DeviceNotes();
        mynote.DeviceId = Int32.Parse(TextBox1.Text);

        mynote.TagId=Int32.Parse(TextBox2.Text);
        mynote.Note=TextBox3.Text;

        var request =
        WebRequest.Create(HOST + "/API/v1/mdm/devices/UDID/66A1DD99B2CC191FEAB20DA10A9D747AED988770/addNote") as HttpWebRequest;
        request.Method = "POST";
        InitializeRequest(request);
        request.ContentType= MIME_TYPE;
        var xmlSerializer=new XmlSerializer(typeof(DeviceNotes));

        string inputString;
        using (var writer =new StringWriter()){

        var xmlNamespace = new XmlSerializerNamespaces();

        xmlNamespace.Add(string.Empty, string.Empty);

        xmlSerializer.Serialize(writer, mynote, xmlNamespace);

        inputString = writer.ToString();
        Label2.Text = writer.ToString();
        }

        byte[] requestBytes = Encoding.UTF8.GetBytes (inputString);
        request.ContentLength = inputString.Length;

        Stream requestStream = request.GetRequestStream();
        requestStream.Write(requestBytes, 0, requestBytes.Length);
        requestStream.Close();

        var response = (HttpWebResponse)request.GetResponse();
        //Console.WriteLine(new StreamReader (response.GetResponseStream()).ReadToEnd());

        Label1.Text = new StreamReader(response.GetResponseStream()).ReadToEnd().ToString();
        response.Close();
        }
        catch (WebException e) {
        if (e.Response != null) {
        var errorMessageStream = e.Response.GetResponseStream();
        string message = new StreamReader (errorMessageStream).ReadToEnd();
        //Console.WriteLine(message);
        Label1.Text = message.ToString();
        } else {
        //Console.WriteLine(e.Message);
        Label1.Text = e.Message;
        }
        }
        catch (Exception e)
        { //Console.WriteLine(e.Message);
        Label1.Text = e.Message;
        }
    }
开发者ID:Curtisspope,项目名称:MDM_API_AW,代码行数:59,代码来源:AddNoteToDevice.aspx.cs

示例3: Start

    void Start()
    {
        txt1 = GameObject.Find("UI/Main/txt1").GetComponent<Text>();
        txt2 = GameObject.Find("UI/Main/txt2").GetComponent<Text>();
        txt3 = GameObject.Find("UI/Main/txt3").GetComponent<Text>();
        txt4 = GameObject.Find("UI/Main/txt4").GetComponent<Text>();

        standby = true;

        if (Application.platform == RuntimePlatform.Android)
        {
            txt4.text = (Application.persistentDataPath + "/" + textFileName + ".txt").ToString();
            lin = 0;
            txt3.text = (Application.dataPath + "/" + textFileName + ".txt").ToString();

            //ta = Resources.Load<TextAsset>(Application.persistentDataPath + "/" + textFileName ) as TextAsset;
            //s = ta.text;
            //ta = Resources.Load(textFileName, typeof(TextAsset)) as TextAsset;
            //s = ta.text;
            sr = new StreamReader
                (new FileStream("URI=File:"+Application.persistentDataPath + "/" + textFileName + ".txt",FileMode.Open));

            txt1.text = sr.ToString();
            txt2.text = ta.text.ToString();

        }
        else
        {
            //sr = new StreamReader
            //    (new FileStream(Application.dataPath + "/06.Res/Text/" + textFileName + ".txt", FileMode.Open));

            sr = new StreamReader
                (new FileStream(Application.streamingAssetsPath + "/" + textFileName + ".txt", FileMode.Open));
            count = 0;
            prize = 0;
            readLine();
            txt1.text = "bbbbb";
            txt2.text = sr.ToString();
            txt3.text = (Application.streamingAssetsPath + "/" + textFileName + ".txt").ToString();
        }

        TextPanal.SetActive(false);
    }
开发者ID:Gibom,项目名称:Unity3D,代码行数:43,代码来源:TextScript.cs


注:本文中的StreamReader.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。