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


C# System.IO.StreamReader.ReadToEnd方法代码示例

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


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

示例1: Compile

        public object Compile(System.IO.Stream Content, List<string> references)
        {
            CodeDomProvider cc = CodeDomProvider.CreateProvider("CSharp");
            CompilerParameters cp = new CompilerParameters();
            cp.OutputAssembly = Environment.CurrentDirectory + "\\Output_csharp.dll";
            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add("System.Core.dll");
            cp.ReferencedAssemblies.Add("System.Data.dll");
            cp.ReferencedAssemblies.Add("System.Xml.dll");
            cp.ReferencedAssemblies.Add("Microsoft.CSharp.dll");

            foreach (string assembly in references)
            {
                cp.ReferencedAssemblies.Add(assembly);
            }

            cp.WarningLevel = 3;

            cp.CompilerOptions = "/target:library /optimize";
            cp.GenerateExecutable = false;
            cp.GenerateInMemory = false; //TODO check this setting

            System.IO.StreamReader sr = new System.IO.StreamReader(Content);

            CompilerResults cr = cc.CompileAssemblyFromSource(cp, sr.ReadToEnd());

            return cr;
        }
开发者ID:rdpeake,项目名称:CodeRunners,代码行数:28,代码来源:CSharpCompiler.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Current.Request.InputStream);
            string requestFromPost = reader.ReadToEnd();

            //loop through
               // string formValue;

            string speed;
            string initialLocation;
            string finalLocation;
            string IMEI;

            if (!string.IsNullOrEmpty(Request.Form["txtSpeed"]))
            {
                //formValue = Request.Form["txtSpeed"];
                //formValue = Request.Form["txtImei"];
                speed = Request.Form["Speed"];
                initialLocation = Request.Form["initialLocation"];
                finalLocation = Request.Form["finalLocation"];
                IMEI = Request.Form["IMEI"];

                string s = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
                SqlConnection cn = new SqlConnection(s);
                cn.Open();
                SqlCommand cmd = new SqlCommand("insert into DataHistory(Speed, initialLocation, finalLocation, IMEI)values('" + speed + "','" + initialLocation + "','" + finalLocation + "','" + IMEI + "')", cn);
                cmd.ExecuteNonQuery();

            }
        }
开发者ID:niviaqua,项目名称:ParentGuardWebApp,代码行数:30,代码来源:DrivingData.aspx.cs

示例3: LoginNormal

        private void LoginNormal(string username,string password,string data,ref CookieContainer cookies)
        {
            //POST login data
            Dictionary<string,string> postData = new Dictionary<string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create ("https://www.livecoding.tv/accounts/login/");
            request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method = "POST";
            request.Referer = "https://www.livecoding.tv/accounts/login/";
            request.ContentType = "application/x-www-form-urlencoded";

            postData.Add ("csrfmiddlewaretoken", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data,"<input type='hidden' name='csrfmiddlewaretoken'"),"value"));
            postData.Add ("login", username);
            postData.Add ("password", password);
            byte[] postBuild = HttpHelper.CreatePostData (postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream ().Write (postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
            using (System.IO.StreamReader sr = new System.IO.StreamReader (response.GetResponseStream ())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
                LoginCompleted (this, cookies);
        }
开发者ID:CsharpLassi,项目名称:LiveCodingChat,代码行数:26,代码来源:EmailLogin.cs

示例4: CallRestful

 /// <summary>
 /// 发起推送请求到信鸽并获得相应
 /// </summary>
 /// <param name="url">url</param>
 /// <param name="parameters">字段</param>
 /// <returns>返回值json反序列化后的类</returns>
 private Ret CallRestful(String url, IDictionary<string, string> parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     if (string.IsNullOrEmpty(url))
     {
         throw new ArgumentNullException("url");
     }
     try
     {
         parameters.Add("access_id", accessId);
         parameters.Add("timestamp", ((int)(DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(
         new System.DateTime(1970, 1, 1))).TotalSeconds).ToString());
         parameters.Add("valid_time", valid_time.ToString());
         string md5sing = SignUtility.GetSignature(parameters, this.secretKey, url);
         parameters.Add("sign", md5sing);
         var res = HttpWebResponseUtility.CreatePostHttpResponse(url, parameters, null, null, Encoding.UTF8, null);
         var resstr = res.GetResponseStream();
         System.IO.StreamReader sr = new System.IO.StreamReader(resstr);
         var resstring = sr.ReadToEnd();
         return JsonConvert.DeserializeObject<Ret>(resstring);
     }
     catch (Exception e)
     {
         return new Ret { ret_code = -1, err_msg = e.Message };
     }
 }
开发者ID:onedot,项目名称:XinGePushSDK.NET,代码行数:35,代码来源:XingeApp.cs

示例5: Index

        //
        // GET: /Proxy/
        public ActionResult Index()
        {
            string key = "<GIMMIE_KEY>";
            string secret = "<GIMMIE_SECRET>";
            string user_id = "<PLAYER_ID>";

            string queryString = Request.Url.Query;
            string[] pathArray = queryString.Split(new string[] { "gimmieapi=" }, StringSplitOptions.None);
            string path = pathArray[pathArray.Length - 1];

            string gimmieRoot = "https://api.gimmieworld.com";
            string endpoint = gimmieRoot + path;

            string access_token_secret = secret;
            string access_token = user_id;
            string url = endpoint;

            var uri = new Uri(url);
            string url2, param;
            var oAuth = new OAuthBase();
            var nonce = oAuth.GenerateNonce();
            var timeStamp = oAuth.GenerateTimeStamp();
            var signature = System.Web.HttpUtility.UrlEncode(oAuth.GenerateSignature(uri, key, secret, access_token, access_token_secret, "GET", timeStamp, nonce, OAuthBase.SignatureTypes.HMACSHA1, out url2, out param));
            var requestURL = string.Format("{0}?{1}&oauth_signature={2}", url2, param, signature);

            WebRequest req = WebRequest.Create(requestURL);
            WebResponse res = req.GetResponse();

            System.IO.Stream sm = res.GetResponseStream();
            System.IO.StreamReader s = new System.IO.StreamReader(sm);

            string output = s.ReadToEnd();

            return new ContentResult { Content = output, ContentType = "application/json" };
        }
开发者ID:gimmie,项目名称:proxies,代码行数:37,代码来源:ProxyController.cs

示例6: Main

        static void Main(string[] args)
        {
            var file = new System.IO.StreamReader("PieCSource/Program.pie");

            string code = file.ReadToEnd();
            file.Close();

            CompilerParameters parameters = new CompilerParameters();
            parameters.ReferencedAssemblies.Add("Pie.dll");
            parameters.ReferencedAssemblies.Add("System.dll");
            parameters.GenerateInMemory = false;
            parameters.OutputAssembly = "piec.exe";
            parameters.GenerateExecutable = true;

            var provider = new PieCodeProvider();
            var results = provider.CompileAssemblyFromSource(parameters, code);

            foreach (CompilerError e in results.Errors)
            {
                Console.WriteLine(e.ErrorNumber + ", " + e.Line + ", " + e.Column + ": " + e.ErrorText);
            }

            if (results.Errors.Count == 0)
            {
                Type program = results.CompiledAssembly.GetType("Program");
                var main = program.GetMethod("Main");

                string[] strings = new string[] { "/out:test.exe", "TestCode/Program.pie", "TestCode/Hello.pie" };
                main.Invoke(null, new object[] { strings });
            }

            Console.ReadKey();
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:33,代码来源:Program.cs

示例7: Get

        /// <summary>
        /// 发送Get请求
        /// </summary>
        /// <param name="url">请求地址</param>
        /// <returns></returns>
        public string Get(string url)
        {
            //System.Net.ServicePointManager.DefaultConnectionLimit = 512;
            //int i = System.Net.ServicePointManager.DefaultPersistentConnectionLimit;
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Accept = "*/*";
            request.Timeout = 20000;
            request.AllowAutoRedirect = false;
            request.ServicePoint.Expect100Continue = false;

            try
            {
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8))
                    {
                        return reader.ReadToEnd();
                    }
                }
                else
                    return response.StatusDescription;
            }
            catch(Exception e)
            {
                return e.Message;
            }
            finally
            {
                request = null;
            }
        }
开发者ID:a79361360,项目名称:GetMoney,代码行数:39,代码来源:Web.cs

示例8: LoadAndExecute

        public ExecutionMirror LoadAndExecute(string fileName, ProtoCore.Core core, bool isTest = true)
        {
            string codeContent = string.Empty;

            try
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(fileName, Encoding.UTF8, true))
                {
                    codeContent = reader.ReadToEnd();
                }
            }
            catch (System.IO.IOException)
            {
                throw new FatalError("Cannot open file " + fileName);
            }

            //Start the timer
            core.StartTimer();
            core.CurrentDSFileName = ProtoCore.Utils.FileUtils.GetFullPathName(fileName);
            core.Options.RootModulePathName = core.CurrentDSFileName;

            Execute(codeContent, core);
            if (!core.Options.CompileToLib && (null != core.CurrentExecutive))
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);

            return null;
        }
开发者ID:samuto,项目名称:designscript,代码行数:27,代码来源:ProtoScriptWebRunner.cs

示例9: ExtractSettingsFromFile

        public bool ExtractSettingsFromFile(String pathFileSettings)
        {
            try
            {
                if (System.IO.File.Exists(pathFileSettings) == true)
                {
                    System.IO.StreamReader myFile = new System.IO.StreamReader(pathFileSettings);
                    string globalContent = myFile.ReadToEnd();

                    myFile.Close();

                    if (globalContent.Contains(LineFileSeparator))
                    {
                        String[] listSettings = globalContent.Split(LineFileSeparator.ToCharArray());

                        for (int indexString = 0; indexString < listSettings.Length; indexString++)
                        {
                            if (listSettings[indexString].Contains(charToRemove.ToString()))
                            {
                                listSettings[indexString] = listSettings[indexString].Remove(listSettings[indexString].IndexOf(charToRemove), 1);
                            }
                        }
                        return ProcessSettings(listSettings);
                    }
                }

                return false;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:AntonioDefinaISMB,项目名称:ShellLauncher,代码行数:33,代码来源:ProjectTypes.cs

示例10: LogError

        private void LogError(HttpContext context)
        {
            try
            {
                string userName, url, data;
                userName = context.User.Identity.Name;
                CommonLogger.Info("NLog HttpException Use Name = '{0}'", userName);
                url = context.Request.Url.ToString();
                CommonLogger.Info("Url = '{0}'", url);

                HttpContext.Current.Request.InputStream.Position = 0;
                using (var reader = new System.IO.StreamReader(context.Request.InputStream))
                {
                    data = reader.ReadToEnd();
                }
                CommonLogger.Info("Data = '{0}'", data);

                foreach (var routeData in HttpContext.Current.Request.RequestContext.RouteData.Values)
                {
                    CommonLogger.Info("userName = '{0}' Key='{1}' Value='{2}'", userName, routeData.Key, routeData.Value);
                }
            }
            catch (Exception e)
            {
                CommonLogger.Error("An error occurs during processing unhandled exception", e);
            }
        }
开发者ID:ProcessingFinancialInformation,项目名称:TFIP,代码行数:27,代码来源:Global.asax.cs

示例11: ExecuteCmdlet

        protected override void ExecuteCmdlet()
        {
            WebPartEntity wp = null;

            if (ParameterSetName == "FILE")
            {
                if (System.IO.File.Exists(Path))
                {
                    System.IO.StreamReader fileStream = new System.IO.StreamReader(Path);
                    string webPartString = fileStream.ReadToEnd();
                    fileStream.Close();

                    wp = new WebPartEntity();
                    wp.WebPartZone = ZoneId;
                    wp.WebPartIndex = ZoneIndex;
                    wp.WebPartXml = webPartString;
                }
            }
            else if (ParameterSetName == "XML")
            {
                wp = new WebPartEntity();
                wp.WebPartZone = ZoneId;
                wp.WebPartIndex = ZoneIndex;
                wp.WebPartXml = Xml;
            }
            if (wp != null)
            {
                this.SelectedWeb.AddWebPartToWebPartPage(PageUrl, wp);
            }
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:30,代码来源:AddWebPartToWebPartPage.cs

示例12: abrirToolStripMenuItem_Click

 //Abrir
 private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     load.Filter = "txt files (*.txt)|*.txt";
     if (load.ShowDialog() == System.Windows.Forms.DialogResult.OK){
         System.IO.StreamReader file = new System.IO.StreamReader(@load.FileName);
         txttexto.Text = file.ReadToEnd();}
 }
开发者ID:RafaelBelle,项目名称:Notepad,代码行数:8,代码来源:frmPrincipal.cs

示例13: Load

        public void Load(string imageFilename)
        {
            this.ImageFilename = imageFilename;
            this.Filename = imageFilename.Replace(SupportedImageFormat, ".txt");
            System.IO.TextReader tr = new System.IO.StreamReader(this.Filename);
            string data = tr.ReadToEnd();
            List<EditingQuad> quads = new List<EditingQuad>();
            DataLoader.ParseData(data).ForEach(q => quads.Add(new EditingQuad(q)));

            myCanvasEditor.Clear();

            Image CalibrationImage = new Image();
            CalibrationImage.Source = new System.Windows.Media.Imaging.BitmapImage(
                new Uri(ImageFilename, UriKind.RelativeOrAbsolute));
            CalibrationImage.Width = 640;
            CalibrationImage.Height = 480;
            CalibrationImage.Stretch = Stretch.Fill;
            myCanvasEditor.Canvas.Children.Add(CalibrationImage);

            foreach (EditingQuad editingQuad in quads)
            {
                myCanvasEditor.Canvas.Children.Add(editingQuad.Polygon);
                editingQuad.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(editingQuad_PropertyChanged);
            }
            myCanvasEditor.EditableUIElements = myCanvasEditor.Canvas.Children;
            MyQuads = quads;
        }
开发者ID:Kaftan777ski,项目名称:mapinect,代码行数:27,代码来源:DataCalibration.cs

示例14: GetUrltoHtml

 /// <summary>
 /// 代理使用示例
 /// </summary>
 /// <param name="Url"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static string GetUrltoHtml(string Url, string type = "UTF-8")
 {
     try
     {
         var request = (HttpWebRequest)WebRequest.Create(Url);
         request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
         WebProxy myProxy = new WebProxy("192.168.15.11", 8015);
         //建议连接(代理需要身份认证,才需要用户名密码)
         myProxy.Credentials = new NetworkCredential("admin", "123456");
         //设置请求使用代理信息
         request.Proxy = myProxy;
         // Get the response instance.
         System.Net.WebResponse wResp = request.GetResponse();
         System.IO.Stream respStream = wResp.GetResponseStream();
         // Dim reader As StreamReader = New StreamReader(respStream)
         using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream, Encoding.GetEncoding(type)))
         {
             return reader.ReadToEnd();
         }
     }
     catch (Exception)
     {
         //errorMsg = ex.Message;
     }
     return "";
 }
开发者ID:CrazyJson,项目名称:TaskManager,代码行数:32,代码来源:Program.cs

示例15: fetchGowallaData

        public string fetchGowallaData(string path)
        {
            var postData = new Dictionary<string,string> () {
                { "access_token", OAuth.AccessToken }};
            var wc = new WebClient ();
            wc.Headers["Accept"] = "application/json";
            wc.Headers.Add("X-Gowalla-API-Key", OAuth.APIKey);

            var pd = PreparePostData(postData);
            try {
                foreach(var h in wc.Headers)
                {
                    Console.WriteLine(h.ToString() + ": " + wc.Headers[h.ToString()].ToString());
                }
                Console.WriteLine(baseUrl + path); //+ "?" + pd );
                //var s = wc.UploadString(baseUrl + path, "");//"?" + pd );
                var b = wc.DownloadData (baseUrl + path + "?" + pd );
                var s = Encoding.UTF8.GetString(b);

                if(!string.IsNullOrEmpty(s.ToString()))
                {
                    return s.ToString();
                }
            } catch (WebException e) {
                var x = e.Response.GetResponseStream ();
                var j = new System.IO.StreamReader (x);
                Console.WriteLine (j.ReadToEnd ());
                Console.WriteLine (e);
                // fallthrough for errors
            }
            return "";
        }
开发者ID:martinbowling,项目名称:GowallaOAuthSample,代码行数:32,代码来源:GowallaAPI.cs


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