我正在尝试将一些双精度值写入用户通过 SaveFileDialog 创建的文本文件,但每次我执行 streamWriterVariable->Write(someDoubleVariable) 时,我都会在文本文件中看到某种奇怪的 ASCII 字符be(音符、|、版权符号等)。如果有任何意义,我会用记事本打开文件。我的代码的基本大纲:
SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
saveFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1->Title = "Save File Here";
saveFileDialog1->RestoreDirectory = true;
if (saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
FileInfo ^fleTest = gcnew FileInfo(saveFileDialog1->FileName);
StreamWriter ^sWriter = fleTest->CreateText();
sWriter->AutoFlush = true;
double test = 5.635; //Some arbitrary double I made up for test purposes
sWriter->Write(test);
sWriter->Flush();
sWriter->Close();
}
谢谢你的帮助!