私はエンコーディングに大きな問題があります。私が使用しているコードはうまくいくはずですが、そうではありません!
ここにコードです:
FileStream fs = new FileStream(saveFile, FileMode.Create, FileAccess.Write, FileShare.None);
System.IO.StreamWriter objWriter;
objWriter = new System.IO.StreamWriter(fs , Encoding.Unicode);
string textLine;
if (System.IO.File.Exists(readFile) == true)
{
System.IO.StreamReader objReader;
objReader = new System.IO.StreamReader(readFile, Encoding.Unicode);
do
{
textLine = objReader.ReadLine();
if (textLine.IndexOf(searchString) != -1)
{
tempString = textLine;
position1 = textLine.IndexOf(searchString);
tempString = textLine.Substring(position1);
if (tempString.IndexOf("(") != -1)
{
position2 = tempString.IndexOf("(");
//MessageBox.Show(tempString.Length.ToString());
tempString = tempString.Substring(0, position2);
}
}
objWriter.WriteLine(textLine);
} while (objReader.Peek() != -1);
}
objWriter.Close();
MessageBox.Show(tempString);
MessageBox.Show("Done!");
英語の文字とキリル文字が混在しているファイルを読み込む必要がありますが、ファイルを読み込んで処理した後、ファイルを新しい場所に保存しようとすると、すべての文字は "?"または他の未知の記号である。私は可能なすべてのエンコードを試して、それは動作しません!