出于某种奇怪的原因,我正在从 .txt(记事本)文件中读取数据,我只想去掉第一个 5 位数字。程序运行后,我的输出文件以我认为是日语的格式打印。我将在下面发布一些代码以及示例输入和输出。任何帮助将不胜感激追查为什么会发生这种情况。谢谢你。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace BasicFileStripper
{
class Program
{
static void Main(string[] args)
{
//var encoding = new ASCIIEncoding();
StreamWriter write = new StreamWriter(@"C:\Users\Josh\Desktop\MillerEpicOutputs\ClientIds.txt");
StreamReader read = new StreamReader(@"C:\Users\Josh\Desktop\MillerEpicOutputs\j.txt");//, encoding);
string line;
int count = 0;
write.Write("{");
while ((line = read.ReadLine()) != null)
{
count++;
string copy = line.Substring(0, 5);
write.Write(copy + ",");
Console.WriteLine(line);
}
write.WriteLine("};");
write.WriteLine("Count: " + count);
write.Close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
样本输入:
68669 - (DO NOT …Run Code Online (Sandbox Code Playgroud)