将 MFC 表单 'text' 处理为 char 类型或常规字符串类型

Dealing with MFC form 'text' as char type or regular string type

在修改别人写的MFC表格时,用Visual Studio2012,遇到问题

在表单中,有一个输入框,其中包含文件的整个路径。 例如)C:\folder1\test_file.wav 在代码中,this->tb_path->Text 包含这个。

第一个问题是我找不到处理 this->tb_path->Text 的方法 char*char 类型数组以使用 string.h

中的方法

现状,代码使用

system:: String ^fileName = this->tb_path->Text + "_re";

修改文本,但这实际上妨碍了对文件路径的各种修改。 我该如何解决这个问题?

尝试

System::String ^fileName = gcnew System::String(this->tb_path->Text + "_re"); 

或者可能是

System::String ^fileName = gcnew System::String(this->tb_path->Text + _T("_re"));

在我看来,您没有使用 gcnew 在内存中进行必要的分配,然后您从未初始化的内存中获取字符串中的垃圾。