国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#使用Streamwriter打開文件的方法

2020-01-24 02:01:13
字體:
來源:轉載
供稿:網友

本文實例講述了C#使用Streamwriter打開文件的方法。分享給大家供大家參考。具體如下:

using System;using System.IO;public class KtoD1 { public static void Main() {  string str;  StreamWriter fstr_out;  // Open the file directly using StreamWriter.  try {   fstr_out = new StreamWriter("test.txt");  }  catch(IOException exc) {   Console.WriteLine(exc.Message + "Cannot open file.");   return ;  }  Console.WriteLine("Enter text ('stop' to quit).");  do {   Console.Write(": ");   str = Console.ReadLine();   if(str != "stop") {    str = str + "/r/n"; // add newline    try {     fstr_out.Write(str);    } catch(IOException exc) {     Console.WriteLine(exc.Message + "File Error");     return ;    }   }  } while(str != "stop");  fstr_out.Close(); }}

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 比如县| 镇原县| 汝城县| 大港区| 黄大仙区| 云林县| 威宁| 永登县| 连城县| 鹤庆县| 新河县| 镇江市| 改则县| 湾仔区| 门源| 财经| 霸州市| 紫云| 红桥区| 耿马| 宾川县| 巧家县| 芜湖县| 乌兰察布市| 温宿县| 泉州市| 桑植县| 密云县| 池州市| 射阳县| 阿合奇县| 象州县| 彝良县| 曲松县| 伊川县| 镇赉县| 南乐县| 罗甸县| 安多县| 威远县| 射阳县|