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


C# StreamReader.ReadToEnd方法代码示例

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


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

示例1: Update

	private void Update()
	{
		if(Input.GetKeyDown(KeyCode.Alpha1))
		{
			Debug.Log ("Incrementing");
			HttpWebRequest webRequestSend = (HttpWebRequest)WebRequest.Create(@"http://www.potato.azurelit.com/IncrementPotato.php");

			webRequestSend.GetResponse().GetResponseStream();
			//if(reader.ReadToEnd() != "")
			//{
			//	Debug.Log("Unkown Return Value: " + reader.ReadToEnd());
			//}
		}

		if(Input.GetKeyDown(KeyCode.Alpha2))
		{
			Debug.Log ("Checking Value");
			HttpWebRequest webRequestCheck = (HttpWebRequest)WebRequest.Create(@"http://www.potato.azurelit.com/GetPotatoCount.php");

			StreamReader reader = new StreamReader(webRequestCheck.GetResponse().GetResponseStream());  
			Debug.Log(reader.ReadToEnd());
		}

		if(Input.GetKeyDown(KeyCode.Alpha3))
		{
			Debug.Log ("Reseting");
			HttpWebRequest webRequestReset = (HttpWebRequest)WebRequest.Create(@"http://www.potato.azurelit.com/ResetPotatoCount.php");

			StreamReader reader = new StreamReader(webRequestReset.GetResponse().GetResponseStream());  
			if(reader.ReadToEnd() != "")
			{
				Debug.Log("Unknown Return Value: " + reader.ReadToEnd());
			}
		}
	}
开发者ID:BenDy557,项目名称:Potato,代码行数:35,代码来源:ServerSQLComm.cs

示例2: Importbtn_Click

    protected void Importbtn_Click(object sender, EventArgs e)
    {
        if (VcardUploader.HasFile)
        {
            if ((VcardUploader.FileName.ToLower().EndsWith(".vcf")) || VcardUploader.FileName.ToLower().EndsWith(".csv"))
            {
                uploaderError.Visible = false;
                VCardCSVParser vcfparser = new VCardCSVParser();
                StreamReader streamReader = new StreamReader(VcardUploader.FileContent);
                if (VcardUploader.FileName.ToLower().EndsWith(".vcf"))
                    GridView1.DataSource = vcfparser.GetRecepientFromVCards(streamReader.ReadToEnd());
                else
                    GridView1.DataSource = vcfparser.GetRecepientFromCSV(streamReader.ReadToEnd(), ",");
                if (((IList)GridView1.DataSource).Count == 0)
                    ShowUploaderError("Can not find any Contact");
                else
                    GridView1.DataBind();

                streamReader.Close();
            }
            else
                ShowUploaderError("You must upload vcf  or scv File");

        }
        else
            ShowUploaderError("Choose file to be imported");
    }
开发者ID:quicksolutions,项目名称:Pets-without-Parents,代码行数:27,代码来源:VCardCSVImporter.aspx.cs

示例3: Main

	static int Main (string [] args)
	{
		if (args.Length != 1) {
			Console.WriteLine ("Please specify action.");
			return 1;
		}

		string basedir = AppDomain.CurrentDomain.BaseDirectory;
		string logfile = Path.Combine (basedir, "debug.log");

		switch (args [0]) {
		case "write":
			TextWriterTraceListener debugLog = new TextWriterTraceListener (logfile);
			Debug.AutoFlush = true;
			Debug.Listeners.Add (debugLog);
			Debug.Write ("OK");
			break;
		case "read":
			using (FileStream fs = new FileStream (Path.Combine (basedir, "debug.log"), FileMode.Open, FileAccess.Read, FileShare.Read)) {
				StreamReader sr = new StreamReader (fs, Encoding.Default, true);
#if ONLY_1_1 && !MONO
				Assert.AreEqual (string.Empty, sr.ReadToEnd (), "#1");
#else
				Assert.AreEqual ("OK", sr.ReadToEnd (), "#1");
#endif
				sr.Close ();
			}
			break;
		}

		return 0;
	}
开发者ID:mono,项目名称:gert,代码行数:32,代码来源:test.cs

示例4: OnPostprocessAllAssets

    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPath)
    {
        foreach(string s in importedAssets){
            if(s.EndsWith(".pts") || s.EndsWith(".ply")){

                string prefabPath = s.Substring(0, s.Length-4) + ".prefab";
                GameObject go = new GameObject("tempObject");
                go.hideFlags = HideFlags.NotEditable;

                PointCloud pc = go.AddComponent<PointCloud>();

                ParticleSystem ps = go.particleSystem;
                ps.loop=true;
                Debug.LogWarning("To get frustum culling working you need to set Prewarm option to true manually in "+prefabPath+" and if it's still not ok set the shape to box ahd it's size to match your pointcloud dimension");
                ps.enableEmission=true;
                ps.playOnAwake=true;
                ps.renderer.castShadows=false;
                ps.renderer.receiveShadows=false;

                go.particleSystem.renderer.material = AssetDatabase.LoadAssetAtPath("Assets/Point.mat", typeof(Material)) as Material;

                //prefab.hideFlags = HideFlags.NotEditable;
                try{
                    using(StreamReader sr = new StreamReader(s)){
                        Debug.Log("loading points!!!");
                        if(s.EndsWith(".pts")){
                            pc.LoadPointsFromPts(sr.ReadToEnd());
                        }
                        else if(s.EndsWith(".ply")){
                            pc.LoadPointsFromPly(sr.ReadToEnd());
                        }
                    }
                }
                catch(Exception e){
                    Debug.LogError(e);
                }

                PrefabUtility.CreatePrefab(prefabPath, go);
                GameObject.DestroyImmediate(go);

                Debug.Log("imported asset "+s);

                //AssetDatabase.CreateAsset(prefab, prefabPath);
                //AssetDatabase.AddObjectToAsset(createPointcloudFromPts(""), s);
            }
        }
        foreach(string s in deletedAssets){
            if(s.EndsWith(".pts")){
                Debug.Log("deleted asset "+s);
            }
        }
        for(int i=0; i<movedAssets.Length; i++){
            if(movedAssets[i].EndsWith(".pts")){
                Debug.Log("moved asset from "+movedFromAssetPath[i]+" to "+movedAssets[i]);
            }
        }
    }
开发者ID:simonbroggi,项目名称:PointCloud,代码行数:57,代码来源:PtsImporter.cs

示例5: PostStream

	static string PostStream (Mono.Security.Protocol.Tls.SecurityProtocolType protocol, string url, byte[] buffer)
	{
		Uri uri = new Uri (url);
		string post = "POST " + uri.AbsolutePath + " HTTP/1.0\r\n";
		post += "Content-Type: application/x-www-form-urlencoded\r\n";
		post += "Content-Length: " + (buffer.Length + 5).ToString () + "\r\n";
		post += "Host: " + uri.Host + "\r\n\r\n";
		post += "TEST=";
		byte[] bytes = Encoding.Default.GetBytes (post);

		IPHostEntry host = Dns.Resolve (uri.Host);
		IPAddress ip = host.AddressList [0];
		Socket socket = new Socket (ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
		socket.Connect (new IPEndPoint (ip, uri.Port));
		NetworkStream ns = new NetworkStream (socket, false);
		SslClientStream ssl = new SslClientStream (ns, uri.Host, false, protocol);
		ssl.ServerCertValidationDelegate += new CertificateValidationCallback (CertificateValidation);

		ssl.Write (bytes, 0, bytes.Length);
		ssl.Write (buffer, 0, buffer.Length);
		ssl.Flush ();

		StreamReader reader = new StreamReader (ssl, Encoding.UTF8);
		string result = reader.ReadToEnd ();
		int start = result.IndexOf ("\r\n\r\n") + 4;
		start = result.IndexOf ("\r\n\r\n") + 4;
		return result.Substring (start);
	}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:28,代码来源:postecho.cs

示例6: btnGetDeviceLocation_Click

    /*
     * User invoked Event to get device location
     * Invoke AT&T Get Device Location api through http web request along with access token
     * and Disaplys the Device Location of given msisdn
     */
    protected void btnGetDeviceLocation_Click(object sender, EventArgs e)
    {
        try
        {
            string strReq = txtDeviceId.Text;
            string access_tkn = txtAcceTokGetDelStatus.Text.ToString();
            String strResult;

            // Form Http Web Request
            HttpWebResponse objResponse;
            HttpWebRequest objRequest = (HttpWebRequest)System.Net.WebRequest.Create("https://beta-api.att.com/1/devices/tel:"+strReq.ToString()+"/location?access_token="+access_tkn.ToString());

            objRequest.Method = "GET";

            objResponse = (HttpWebResponse)objRequest.GetResponse();
            // the using keyword will automatically dispose the object
            // once complete
            using (StreamReader sr2 = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr2.ReadToEnd();
                Response.Write(strResult.ToString());

                // Close and clean up the StreamReader
                sr2.Close();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
开发者ID:tanand,项目名称:new_bf_staging,代码行数:36,代码来源:Default.aspx.cs

示例7: Main

    static void Main()
    {
        var reader = new StreamReader("..\\..\\input.txt");
        string[] input = reader.ReadToEnd().Split(' ');
        reader.Close();
        string deletedWord = "start";
        string newWord = "finish";
        for (int i = 0; i < input.Length; i++)
        {
            if (input[i]==deletedWord)
            {
                input[i] = newWord;
            }
        }
        string result = string.Join(" ", input);
        var writer = new StreamWriter("..\\..\\result.txt");
        using (writer)
        {
            if (result != null)
            {
                writer.WriteLine(result);
            }

        }
    }
开发者ID:DanteSparda,项目名称:TelerikAcademy,代码行数:25,代码来源:Program.cs

示例8: Read

 public static string Read(string path)
 {
     var reader = new StreamReader(path);
     var s = reader.ReadToEnd();
     reader.Close();
     return s;
 }
开发者ID:arahis,项目名称:Swiper,代码行数:7,代码来源:Reader.cs

示例9: GetCall

    private string GetCall(string uri)
    {
        Stream stream = null;
        StreamReader streamReader;
        try
        {
            //uri = "https://www.google.com";
            //Creates a new WebRequest object with the URI and specifies its method.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            //request.Method = "POST";

            //Obtains the response from the website.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            //Opens a stream from the website then pipes it to a StreamReader with proper encoding.
            stream = response.GetResponseStream();
            streamReader = new StreamReader(stream, Encoding.UTF8);

            string jsonResult = streamReader.ReadToEnd();

            return jsonResult;
        }
        //If an error occured, return null
        catch (WebException e)
        {
            return null;
        }
    }
开发者ID:gabrielr-tkf,项目名称:smartoffmedia,代码行数:28,代码来源:WebRESTService.cs

示例10: Main

 static void Main()
 {
     StreamReader reader1 = new StreamReader("test1.txt");
     StreamReader reader2 = new StreamReader("test2.txt");
     string joined = reader1.ReadToEnd() + " " + reader2.ReadToEnd();
     Console.WriteLine(joined);
 }
开发者ID:hackohackob,项目名称:TelerikAcademy,代码行数:7,代码来源:02.JoinTwoTextFiles.cs

示例11: Load

 public static String Load(string path){
   if(!Exists(path)) return "";
   StreamReader r = new StreamReader(CompletePath(path));
   string raw = r.ReadToEnd();
   r.Close();
   return raw;
 }
开发者ID:awatemonosan,项目名称:unity-essentials,代码行数:7,代码来源:PData.cs

示例12: Main

    internal static void Main()
    {
        var reader = new StreamReader(@"..\..\words.txt");
        char[] separators = { ' ', '.', ',', '!', '?', '–' };

        using (reader)
        {
            string all = reader.ReadToEnd();
            string[] words = all.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            var result = new Dictionary<string, int>();

            for (int i = 0; i < words.Length; i++)
            {
                if (result.ContainsKey(words[i].ToLower()))
                {
                    result[words[i].ToLower()]++;
                }
                else
                {
                    result[words[i].ToLower()] = 1;
                }
            }

            foreach (var item in result.OrderBy(x => x.Value))
            {
                Console.WriteLine("{0} -> {1} {2}", item.Key, item.Value, item.Value == 1 ? "time" : "times");
            }
        }
    }
开发者ID:kalinalazarova1,项目名称:TelerikAcademy,代码行数:29,代码来源:WordOccurrenciesInText.cs

示例13: facebookCheckAuthorisation

    public String facebookCheckAuthorisation()
    {
        string accessToken = "";
        //String scope = "public_profile,user_actions.news,user_education_history,user_posts,user_status,user_work_history,publish_stream,manage_pages";
        String scope = "rsvp_event,publish_pages,read_mailbox,rsvp_event,email,publish_actions,read_insights,read_stream,user_about_me,user_actions.music,user_birthday,user_friends,user_hometown,user_managed_groups,user_relationship_details,user_status,user_website,user_actions.books,user_actions.news,user_education_history,user_likes,user_photos,user_relationships,user_tagged_places,user_work_history,user_actions.video,user_events,user_groups,user_location,user_posts,user_religion_politics,user_videos,manage_pages";
        if(HttpContext.Current.Request["code"] == null)
        {
            HttpContext.Current.Response.Redirect(String.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
                facebookAppId, HttpContext.Current.Request.Url.AbsoluteUri, scope));
        } else
        {
            Dictionary<String, String> tokens = new Dictionary<string,string>();

            string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
                facebookAppId, HttpContext.Current.Request.Url.AbsoluteUri, scope, HttpContext.Current.Request["code"].ToString(), facebookAppSecret);

            HttpWebRequest myRequest = WebRequest.Create(url) as HttpWebRequest;

            using(HttpWebResponse myResponse = myRequest.GetResponse() as HttpWebResponse)
            {
                StreamReader myReader = new StreamReader(myResponse.GetResponseStream());

                string valsArray = myReader.ReadToEnd();

                foreach(string token in valsArray.Split('&'))
                {
                    tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, (token.Length - token.IndexOf("=") - 1)));
                }
            }
            accessToken = tokens["access_token"];
            this.storeAccessToken(accessToken);
        }
        return accessToken;
    }
开发者ID:lilylakshi,项目名称:second-year-group-project,代码行数:34,代码来源:InfoModule.cs

示例14: btnImport_Click

    protected void btnImport_Click(object sender, EventArgs e)
    {
        string path = @"C:\Inetpub\wwwroot\File\" + txtFileName.Text;
        StreamReader sr = new StreamReader(path);

        string strTextToSplit = sr.ReadToEnd();
        strTextToSplit = strTextToSplit.Replace("\r", "");
        string[] arr = strTextToSplit.Split(new char[] { '\n' });

        for (int i = 0; i < arr.GetUpperBound(0); i++)
        {
            arr[i] = arr[i].Replace("Type=\"Number\"", "Type=\"String\"");
            if (arr[i].Substring(0, 13) == "<Row><Cell ss") arr[i] = "";
            if (arr[i].Length > 50 && arr[i].Substring(0, 52) == "<Row><Cell><Data ss:Type=\"String\">Lines with Errors:") arr[i] = "";
            if (arr[i].IndexOf("This Student has already") != -1) arr[i] = "";
        }

        path = @"C:\Inetpub\wwwroot\File\" + txtFileName.Text + ".xml";
        if (File.Exists(path))
        {
            File.Delete(path);
        }

        using (StreamWriter sw = new StreamWriter(path))
        {
            foreach (string s in arr)
            {
                sw.WriteLine(s);
            }
            sw.Close();
        }
        sr.Close();

        Response.Write("DONE");
    }
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:35,代码来源:CP_StartImportText.aspx.cs

示例15: Main

	static void Main (string [] args)
	{
		int i = 0;

		while (args [i].StartsWith ("-")){
			if (args [i] == "-debug")
				debug = true;
			if (args [i] == "-headers")
				headers = true;
			if (args [i] == "-header")
				header = args [++i];
			i++;
		}
		
		c = new TcpClient (args [i], Int32.Parse (args [i+1]));
		c.ReceiveTimeout = 1000;
		ns = c.GetStream ();
		
		sw = new StreamWriter (ns);
		sr = new StreamReader (ns);

		string host = args [i];
		if (args [i+1] != "80")
			host += ":" + args [i+1];
		send (String.Format ("GET {0} HTTP/1.1\r\nHost: {1}\r\n\r\n", args [i+2], host));

		MemoryStream ms = new MemoryStream ();
		
		try {
			byte [] buf = new byte [1024];
			int n;
			
			while ((n = ns.Read (buf, 0, 1024)) != 0){
				ms.Write (buf, 0, n);
			}
		} catch {}

		ms.Position = 0;
		sr = new StreamReader (ms);

		string s;
		
		while ((s = sr.ReadLine ()) != null){
			if (s == ""){
				if (headers)
					return;
				
				string x = sr.ReadToEnd ();
				Console.Write (x);
				break;
			}  else {
				if (debug || headers)
					Console.WriteLine (s);
				if (header != null && s.StartsWith (header)){
					Console.WriteLine (s);
					return;
				}
			}
		}
	}
开发者ID:nobled,项目名称:mono,代码行数:60,代码来源:rtest.cs


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