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


C# StreamReader.ReadToEnd方法代码示例

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


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

示例1: DlgTips_Load

        private void DlgTips_Load(object sender, EventArgs e)
        {   
            try
            {
                string strxml = "";
                using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
                {
                    strxml = streamReader.ReadToEnd();
                }

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);

                if (objXmlDoc == null)
                    return;

                DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    _versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
                    cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
                }

                chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
                cmbVersion.SelectedIndex = 0;
                SetTextValue();
                btnOk.Select();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgTips", ex);
            }
        }
开发者ID:jojozhuang,项目名称:Projects,代码行数:34,代码来源:DlgTips.cs

示例2: Extract

        public static void Extract(Category category)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Extract");
            if(!Directory.Exists(path))
                Directory.CreateDirectory(path);

            pset.Clear();
            pdic.Clear();
            string downPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Down", category.Name);
            string fileName = string.Format(@"{0}\{1}.txt", path, category.Name);

            StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8);
            for (int i = category.DownPageCount; i >= 1; i--)
            {
                string htmlFileName = string.Format(@"{0}\{1}.html", downPath, i);
                if (!File.Exists(htmlFileName))
                    Logger.Instance.Write(string.Format("{0}-{1}.html-not exist", category.Name, i));
                StreamReader sr = new StreamReader(htmlFileName, Encoding.UTF8);
                string text = sr.ReadToEnd();
                sr.Close();

                var action = CreateAction(category.Type);
                if (action == null) continue;

                Extract(text, sw, category.Name,category.DbName, action);
            }
            sw.Close();

            Console.WriteLine("{0}:Extract Data Finished!", category.Name);
        }
开发者ID:tavenli,项目名称:gaopincai,代码行数:30,代码来源:ExtractData.cs

示例3: GetDealClosingCostTypesFromDeepBlue

 public static List<DeepBlue.Models.Entity.DealClosingCostType> GetDealClosingCostTypesFromDeepBlue(CookieCollection cookies)
 {
     // Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc
     List<DeepBlue.Models.Entity.DealClosingCostType> dealClosingCostTypes = new List<DeepBlue.Models.Entity.DealClosingCostType>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc");
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, null, false, cookies, false, HttpWebRequestUtil.JsonContentType);
     if (response.StatusCode == System.Net.HttpStatusCode.OK) {
         using (Stream receiveStream = response.GetResponseStream()) {
             // Pipes the stream to a higher level stream reader with the required encoding format.
             using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                 string resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     FlexigridData flexiGrid = (FlexigridData)js.Deserialize(resp, typeof(FlexigridData));
                     foreach (Helpers.FlexigridRow row in flexiGrid.rows) {
                         DeepBlue.Models.Entity.DealClosingCostType dealClosingType = new DeepBlue.Models.Entity.DealClosingCostType();
                         dealClosingType.DealClosingCostTypeID = Convert.ToInt32(row.cell[0]);
                         dealClosingType.Name = Convert.ToString(row.cell[1]);
                         dealClosingCostTypes.Add(dealClosingType);
                     }
                 }
                 else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return dealClosingCostTypes;
 }
开发者ID:jsingh,项目名称:DeepBlue,代码行数:31,代码来源:DealImport.cs

示例4: ReadFromFSLocation

 private string ReadFromFSLocation(string path)
 {
     using (StreamReader sr = new StreamReader(path))
     {
         return sr.ReadToEnd().Trim();
     }
 }
开发者ID:mikekberg,项目名称:GIOPL.NET,代码行数:7,代码来源:EdisonDevicePinService.cs

示例5: sendMessage

 private void sendMessage()
 {
     MailAddress adresa = new MailAddress("[email protected]");
     MailMessage zpráva;
     if (logFile)
     {
         string log;
         using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Info", "Log", "logStatusBaru.log")))
         {
             log = reader.ReadToEnd();
         }
         if (log.Length > 50000)
             log.Remove(50000);
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text + log);
     }
     else
     {
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text);
     }
     SmtpClient klient = new SmtpClient();
     klient.Host = "smtp.gmail.com";
     klient.Port = 465;
     klient.EnableSsl = true;
     //klient.Send(zpráva);
 }
开发者ID:Cendrb,项目名称:UTU,代码行数:25,代码来源:OdeslatNázor.xaml.cs

示例6: LoadXml

        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
开发者ID:tpf89,项目名称:mods.de-XML-Parser-for-Windows,代码行数:38,代码来源:Helper.cs

示例7: GeoIP

        public GeoIP()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
                request.Proxy = null;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseString = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);

                WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
                Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
                CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
                Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
                City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
            }
            catch
            {
                WANIP = "-";
                Country = "Unknown";
                CountryCode = "-";
                Region = "Unknown";
                City = "Unknown";
            }
        }
开发者ID:kr-app-a72,项目名称:Computer-Info,代码行数:32,代码来源:GeoIP.cs

示例8: Shader

        public Shader(GraphicsDevice dev, string name)
        {
            this.dev = dev;
            string code;
            using (var file = new StreamReader(FileSystem.Open("cg{0}{1}.fx".F(Path.DirectorySeparatorChar, name))))
                code = file.ReadToEnd();
            effect = Tao.Cg.Cg.cgCreateEffect(dev.Context, code, null);

            if (effect == IntPtr.Zero)
            {
                var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
                var results = Tao.Cg.Cg.cgGetLastListing(dev.Context);
                throw new InvalidOperationException(
                    "Cg compile failed ({0}):\n{1}".F(err, results));
            }

            technique = Tao.Cg.Cg.cgGetFirstTechnique(effect);
            if (technique == IntPtr.Zero)
                throw new InvalidOperationException("No techniques");
            while (Tao.Cg.Cg.cgValidateTechnique(technique) == 0)
            {
                technique = Tao.Cg.Cg.cgGetNextTechnique(technique);
                if (technique == IntPtr.Zero)
                    throw new InvalidOperationException("No valid techniques");
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:26,代码来源:Shader.cs

示例9: Delete

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="fileName"></param>
        public void Delete(string fileName)
        {
            try
            {
                string uri = ftpURI + fileName;
                FtpWebRequest reqFTP;
                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                reqFTP.KeepAlive = false;
                reqFTP.Method = WebRequestMethods.Ftp.DeleteFile;

                string result = String.Empty;
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                long size = response.ContentLength;
                Stream datastream = response.GetResponseStream();
                StreamReader sr = new StreamReader(datastream);
                result = sr.ReadToEnd();
                sr.Close();
                datastream.Close();
                response.Close();
            }
            catch (Exception ex)
            {
                Insert_Standard_ErrorLog.Insert("FtpWeb", "Delete Error --> " + ex.Message + "  文件名:" + fileName);
            }
        }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:31,代码来源:FtpWeb.cs

示例10: Main

        public static void Main()
        {
            var url = new Uri(ApiUrl + "?auth-id=" + AuthenticationID + "&auth-token=" + AuthenticationToken);
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";

            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream))
                writer.Write(RequestPayload);

            using (var response = request.GetResponse())
            using (var stream = response.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var rawResponse = reader.ReadToEnd();
                Console.WriteLine(rawResponse);

                // Suppose you wanted to use Json.Net to pretty-print the response (delete the next two lines if not):
                // Json.Net: http://http://json.codeplex.com/
                dynamic parsedJson = JsonConvert.DeserializeObject(rawResponse);
                Console.WriteLine(JsonConvert.SerializeObject(parsedJson, Formatting.Indented));

                // Or suppose you wanted to deserialize the json response to a defined structure (defined below):
                var candidates = JsonConvert.DeserializeObject<CandidateAddress[]>(rawResponse);
                foreach (var address in candidates)
                    Console.WriteLine(address.DeliveryLine1);
            }

            Console.ReadLine();
        }
开发者ID:42shadow42,项目名称:LiveAddressSamples,代码行数:30,代码来源:street-address-batch.cs

示例11: AppendToVCProjectItemsVsDir

        private static void AppendToVCProjectItemsVsDir(string projectItemsFile)
        {
            var nameSpace = Assembly.GetExecutingAssembly().GetName().Name;
            var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.VCProjectItems_vsdir_append.txt", nameSpace));
            if (resourceStream == null)
                throw new Exception("Missing resource: VCProjectItems_vsdir_append.txt");

            bool needsNewLine = false;
            var readContents = File.ReadAllText(projectItemsFile);
            if (!readContents.EndsWith(Environment.NewLine))
            {
                needsNewLine = true;
            }

            using (var reader = new StreamReader(resourceStream))
            {
                string contents;
                if (needsNewLine)
                {
                    contents = Environment.NewLine + reader.ReadToEnd();
                }
                else
                {
                    contents = reader.ReadToEnd();
                }

                File.AppendAllText(projectItemsFile, contents);
                Console.WriteLine(string.Format("installed: {0}", projectItemsFile));
            }
        }
开发者ID:SCRUMdifferent,项目名称:specflowC,代码行数:30,代码来源:Program.cs

示例12: GetCss

        private static void GetCss(IEnumerable<FileInfo> files, out string css, out string cssmini)
        {
            Global.Log.Debug("Rebuilding CSS.");
            var output = new StringBuilder("/* Generated on {0} */\n".F(DateTime.Now));

            foreach (var file in files) {
                using (var stream = file.Open(FileMode.Open)) {
                    using (var reader = new StreamReader(stream)) {
                        // Append a little comment with the filename separating each file for clarity
                        output.Append("\n/********\n * {0}  \n */\n\n".F(file.Name));
                        switch (file.Extension) {
                            case ".css":
                                output.Append(reader.ReadToEnd());
                                break;
                            case ".less":
                                output.Append(Less.Parse(reader.ReadToEnd()));
                                break;
                        }
                    }
                }
            }

            css = output.ToString();
            cssmini = Compress(output.ToString());
        }
开发者ID:jaysan1292,项目名称:COMP-3073-Group-Project,代码行数:25,代码来源:CssService.cs

示例13: HTTPConnection

        public HTTPConnection(HttpListenerContext c)
        {
            context = c;

            HttpListenerRequest request = context.Request;

            arguments.Clear();

            // get our base keys
            if (request.QueryString.HasKeys())
            {
                for (int i = 0; i < request.QueryString.Count; i++)
                {
                    string name = request.QueryString.GetKey(i);
                    string value = string.Empty;

                    if (request.QueryString.GetValues(i).GetLength(0) > 0)
                        value = request.QueryString.GetValues(i)[0];

                    arguments.Add(name, value);
                }
            }

            if (request.HttpMethod == "POST")
            {
                StreamReader reader = new System.IO.StreamReader(request.InputStream, request.ContentEncoding);
                string body = reader.ReadToEnd();

                while (body.Length < request.ContentLength64) // go untill we have the entire thing
                {
                    body += reader.ReadToEnd();
                    Thread.Sleep(100);
                    Console.WriteLine("readloop body read " + body.Length.ToString() + " : expected size " + request.ContentLength64.ToString() + "request flag " + request.HasEntityBody.ToString());
                }

                reader.Close();
                request.InputStream.Close();

                string[] pairs = body.Split('&');

                foreach (string s in pairs)
                {
                    string[] item = s.Split('=');

                    string name = item[0];
                    string value = string.Empty;

                    if (item.Length > 1 && item[1].Length > 0)
                        value = HttpUtility.UrlDecode(item[1]);

                    if (!arguments.ContainsKey(name))
                        arguments.Add(name, value);
                    else
                        arguments[name] = value;

                    Console.WriteLine("argument " + name + " : " + value);

                }
            }
        }
开发者ID:szakats,项目名称:bzflag_mirror,代码行数:60,代码来源:HTTPConnection.cs

示例14: GET

 public string GET(string url, Encoding _encoding, Boolean needHeaders = false)
 {
     try
     {
         HttpWebRequest hwrq = CreateRequest(url);
         if (Environment.UserDomainName == "GRADIENT")
             hwrq.Credentials = CredentialCache.DefaultNetworkCredentials;
         else
         {
             Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
             Decryptor decryptor = new Decryptor(currentConfig.AppSettings.Settings["Password"].Value);
             hwrq.Credentials = new NetworkCredential(currentConfig.AppSettings.Settings["User"].Value, decryptor.DescryptStr, currentConfig.AppSettings.Settings["Domian"].Value);
         }
         hwrq.CookieContainer = Cookies;
         using (HttpWebResponse hwrs = (HttpWebResponse)hwrq.GetResponse())
         {
             Cookies.Add(hwrs.Cookies);
             using (StreamReader sr = new StreamReader(hwrs.GetResponseStream(), _encoding))
             {
                 if (needHeaders)
                     return hwrs.Headers.ToString() + sr.ReadToEnd().Trim();
                 else
                     return sr.ReadToEnd().Trim();
             }
         }
     }
     catch (Exception e)
     {
         return null;
     }
 }
开发者ID:death-mouse,项目名称:tempTrello,代码行数:31,代码来源:Browser.cs

示例15: Download

        public static HtmlDocument Download(AbsoluteUri location)
        {
            if (null == location)
            {
                throw new ArgumentNullException("location");
            }

            HtmlDocument html = null;

            var request = WebRequest.Create((Uri)location);
            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    if (null != stream)
                    {
                        using (var reader = new StreamReader(stream))
                        {
#if NET20
                            var file = new FileInfo(StringExtensionMethods.FormatWith("{0}.html", AlphaDecimal.Random()));
                            FileInfoExtensionMethods.Create(file, reader.ReadToEnd());
#else
                            var file = new FileInfo("{0}.html".FormatWith(AlphaDecimal.Random()));
                            file.Create(reader.ReadToEnd());
#endif

                            html = new HtmlDocument();
                            html.Load(file.FullName);
                        }
                    }
                }
            }

            return html;
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:35,代码来源:HtmlUriAttribute.cs


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