在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
class Program { public static int ROW = 5; public static int COL = 6; static string[,] str = new string[ROW, COL]; static void Main(string[] args) { Read(); Write(); } public static void Read() { string[] a; StreamReader sr = new StreamReader("D:\\imx_2016-2017\\study\\001.txt", Encoding.Default); for (int i = 0; i < ROW; i++) { String line = sr.ReadLine(); a = line.Split(','); for (int j = 0; j < COL; j++) { str[i, j] = a[j]; //Console.Write(str[i, j]); //Console.Write("\t"); } //Console.WriteLine(); } //Console.ReadKey(); } public static void Write() { FileStream fs = new FileStream("D:\\imx_2016-2017\\study\\002.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); for (int i = 0; i < ROW; i++) { for (int j = 0; j < COL; j++) { sw.Write(str[i,j]); } sw.WriteLine(); } //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论