﻿
{"id":588,"date":"2012-05-19T15:59:50","date_gmt":"2012-05-19T15:59:50","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=588"},"modified":"2012-05-19T15:59:50","modified_gmt":"2012-05-19T15:59:50","slug":"streamreader-sinifi","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/streamreader-sinifi\/","title":{"rendered":"StreamReader S\u0131n\u0131f\u0131"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>StreamReader s\u0131n\u0131f\u0131 sayesinde belirtti\u011fimiz dosyalar\u0131n i\u00e7indeki verileri ister string olarak, istersekte karakter olarak okuyabiliriz.<br \/>\n<!--more--><br \/>\n\u00d6ncelikle C:\/Dosya\/YaziDosya.txt ad\u0131nda bir dosya olu\u015fturup i\u00e7ine a\u015fa\u011f\u0131daki c\u00fcmleleri yaz\u0131yorum.<br \/>\n***<br \/>\nGen\u00e7ay Y\u0131ld\u0131z<br \/>\n1992<br \/>\nArtvin Arhavi<br \/>\n***<br \/>\n\u015eimdi YaziDosya.txt dosyam\u0131zdaki verileri \u00e7ekip okuyal\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StreamReader sr = new StreamReader(&quot;C:\/Dosya\/YaziDosya.txt&quot;);\r\n            MessageBox.Show(sr.ReadToEnd());\r\n            sr.Close();\r\n<\/pre>\n<p><em><strong>NOT!!!Stream s\u0131n\u0131flar\u0131n\u0131 kullan\u0131yorsan\u0131z e\u011fer, i\u015finiz bitince o nesneyi Close() etmeyi unutmay\u0131n\u0131z&#8230;.!!!<\/strong><\/em><\/p>\n<p><strong>ReadToEnd()<\/strong> : Bu metod sayesinde verilen dizindeki dosyan\u0131n b\u00fct\u00fcn de\u011feri elde edilebilir.<br \/>\nYukar\u0131daki kod blo\u011funu \u00e7al\u0131\u015ft\u0131r\u0131rsan\u0131z e\u011fer mesaj kutusunda YaziDosya.txt dosyas\u0131ndaki yaz\u0131lar g\u00f6receksiniz.E\u011fer T\u00fcrk\u00e7e karakter sorunu g\u00f6r\u00fcrseniz \u015fa\u015f\u0131rmay\u0131n\u0131z.\u00c7\u00fcnk\u00fc karakter kodunu belirtmedi\u011fimiz i\u00e7in bu hata olas\u0131d\u0131r.Bu hataya ileride bahsedece\u011fim Encoding s\u0131n\u0131flar\u0131 sayesinde \u00e7\u00f6z\u00fcm getirece\u011fiz.<\/p>\n<p>ReadToEnd() metodu ile YaziDosya.txt dosyas\u0131ndaki de\u011ferleri bir anda \u00e7ektik.\u015eimdide bu de\u011feri sat\u0131r sat\u0131r okumay\u0131 g\u00f6relim.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StreamReader sr = new StreamReader(&quot;C:\/Dosya\/YaziDosya.txt&quot;);\r\n            MessageBox.Show(sr.ReadLine());\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funu \u00e7al\u0131\u015ft\u0131r\u0131rsan\u0131z mesaj kutusunda &#8220;Gen\u00e7ay Y\u0131ld\u0131z&#8221; yaz\u0131s\u0131n\u0131 g\u00f6r\u00fcrs\u00fcn\u00fcz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StreamReader sr = new StreamReader(&quot;C:\/Dosya\/YaziDosya.txt&quot;);\r\n            MessageBox.Show(sr.ReadLine() + &quot;\\n&quot; + sr.ReadLine());\r\n            sr.Close();\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funu \u00e7al\u0131\u015ft\u0131r\u0131rsan\u0131z e\u011fer, mesaj kutusunda &#8220;Gen\u00e7ay Y\u0131ld\u0131z&#8221; ve alt\u0131nda &#8220;1992&#8221; yaz\u0131s\u0131n\u0131 g\u00f6r\u00fcrs\u00fcn\u00fcz.<br \/>\nAnlatmak istedi\u011fim ReadLine() metodu sayesinde sat\u0131r sat\u0131r veriyi okuyabiliriz.Her yaz\u0131\u015f\u0131m\u0131zda bir alttaki veriyi okuyacakt\u0131r.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>StreamReader s\u0131n\u0131f\u0131 sayesinde belirtti\u011fimiz dosyalar\u0131n i\u00e7indeki verileri ister string olarak, istersekte karakter olarak okuyabiliriz.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12],"tags":[224],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-c-sharp-c","tag-streamreader"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}