如何转换系统字符串以将其用作文件名?这是我的程序的骨架。我已经尝试了2年。请! [英] How do I convert System String to use it as the file names? Here is a skeleton of my program. I've tried for 2 years. PLEASE!
本文介绍了如何转换系统字符串以将其用作文件名?这是我的程序的骨架。我已经尝试了2年。请!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
***删除了所有设计师锅炉板代码。它与问题无关。 ***
*** Removed all designer boiler plate code. It has nothing to do with the problem. ***
private: System::Void executeButton_Click(System::Object^ sender, System::EventArgs^ e)
{
ifstream myInfile ("ReadText.txt");
ofstream myOutfile ("SaveText.txt");
if (myInfile.is_open())
{
do
{
char chOne;
myInfile.get(chOne);
// I want to manipulate the input here, which I'm unable to do using stream.
myOutfile.put(chOne);
} while (!myInfile.eof());
myInfile.close();
myOutfile.close();
Form1::~Form1();
}
else
{
Form1::~Form1();
}
}
[edit]
从OP中添加不同的问题:
只是你知道,我想要做的就是将文件名输入到两个文本框(系统字符串)中,并将它们分配给我的ifstream和ofstream。我尝试过字符串转换和Marshal。我得到的是Elem Trait错误和某种误导错误。
[/ edit]
[edit]
Added from OP different question:
Just so you know, all I want to do is input file names into two text boxes(System String), and assign them to my ifstream and ofstream. I've tried string conversion and Marshal. All I get are Elem Trait errors and some kind of misdirection errors.
[/edit]
推荐答案
不要使用C方法操纵文件。请改用.NET System.IO类。
Don't use the C methods of manipulating files. Use the .NET System.IO classes instead.
这篇关于如何转换系统字符串以将其用作文件名?这是我的程序的骨架。我已经尝试了2年。请!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文