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


C# System.IO.StreamWriter.WriteAsync方法代码示例

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


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

示例1: escribirMensaje

        //Metodo hace la copia de seguridad
        public void escribirMensaje()
        {
            int numFilas = dgvTabla.Rows.Count;//Cuenta el numero de filas que tiene la tabla
            String txtOrigen = "";
            String txtDestino = "";
            String texto = "";

                //crea el fichero
                System.IO.StreamWriter file = new System.IO.StreamWriter(this.ruta, true);
                //Crear objeto StringBuilder para escribir un texto
                StringBuilder sb = new StringBuilder();

                //Mientras la lista mensaje esta vacia
                while( !lmsg.Is_Empty())
                {
                    //devuelve el primer mensaje de la lista, con el origen,destino y el texto. Despues borra el msg de la lista
                    Mensaje msg = lmsg.Get_First();
                    txtOrigen=msg.getOrigen();
                    txtDestino = msg.getDestino();
                    texto = msg.getMensaje();
                    lmsg.Remove_First();

                //Agregar mensaje al objeto
                sb.AppendLine("Origen: " + txtOrigen + "#" + " Destino: " + txtDestino + "#" + " Texto: " + texto + "##");

                }
                //escribe el mensaje en el fichero de texto
                file.WriteAsync(sb.ToString());
                file.Close();
        }
开发者ID:aitorlomu,项目名称:DisenoDeInterfaces,代码行数:31,代码来源:FormMensaje.cs

示例2: CreateAccent

 public static void CreateAccent(string name, Color highlight, Color accent)
 {
     using (var sw = new System.IO.StreamWriter(System.IO.File.Create(System.IO.Path.Combine(MeCore.DataDirectory, "Color", name + ".xaml")))) {
         string s = System.Windows.Markup.XamlWriter.Save(createResourceDictionary(highlight, accent));
         System.Threading.Tasks.Task.WaitAll(sw.WriteAsync(s));
     }
 }
开发者ID:cvronmin,项目名称:metocraft,代码行数:7,代码来源:AccentHelper.cs

示例3: Execute

        public override async Task Execute(IHttpRequestResponseContext context)
        {
            SetStatus(context);
            context.Response.ContentLength64 = response.Length;
            context.Response.SendChunked = false;
            context.Response.ContentType = "text/html";

            using (context.Response.OutputStream)
            using (var tw = new System.IO.StreamWriter(context.Response.OutputStream, UTF8.WithoutBOM, 65536, true))
                await tw.WriteAsync(response);
        }
开发者ID:Yoodaa,项目名称:aardwolf,代码行数:11,代码来源:ContentResponse.cs

示例4: ExecuteRequestAsync

        public async Task<HttpProgressInfo> ExecuteRequestAsync(string url, Dictionary<string,string> headers = null, string method = "GET", JToken body = null)
        {
            var pi = new HttpProgressInfo();
            pi.Url = new Uri(url);
            pi.Method = method;
            pi.RequestHeaders = new WebHeaderCollection();

            var req = WebRequest.CreateHttp(url);
            req.Method = method;

            if (headers != null)
            {
                foreach (var i in headers)
                {
                    req.Headers.Add(i.Key, i.Value);
                    pi.RequestHeaders.Add(i.Key, i.Value);
                }
            }

            pi.RequestBody = body == null ? null : body.DeepClone();
            pi.RequestStarted = DateTime.UtcNow;
            pi.State = HttpTransactionState.Started;
            OnProgress(pi);

            if (body != null)
            {
                using (var rs = await req.GetRequestStreamAsync())
                using (var sw = new System.IO.StreamWriter(rs))
                {
                    await sw.WriteAsync(body.ToString(Formatting.None));
                }
            }
            
            pi.RequestCompleted = DateTime.UtcNow;
            pi.State = HttpTransactionState.RequestSent;
            OnProgress(pi);

            var res = (HttpWebResponse)await req.GetResponseAsync();

            pi.State = HttpTransactionState.HeadersReceived;
            pi.ResponseStarted = DateTime.UtcNow;
            pi.ResponseStatus = res.StatusCode;
            pi.ResponseStatusDescription = res.StatusDescription;
            pi.ResponseHeaders = res.Headers;
            OnProgress(pi);

            using (var rs = res.GetResponseStream())
            using (var sr = new System.IO.StreamReader(rs, Encoding.UTF8))
            {
                var dataText = await sr.ReadToEndAsync();

                pi.State = HttpTransactionState.Complete;
                pi.ResponseCompleted = DateTime.UtcNow;

                if (!string.IsNullOrWhiteSpace(dataText))
                {
                    var tok = JToken.Parse(dataText);
                    pi.ResponseBody = tok;
                }
            }

            OnProgress(pi);

            return pi;
        }
开发者ID:kythyria,项目名称:gallus,代码行数:65,代码来源:Http.cs


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