I am using visual c++ 2005 .net and I am looking to create a file from this form. I want to be able to name the file by entering what ever is in the text box. Any help would be greatly appreciated.
Here is the form:

this is what I have so far:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ path = "C:\\" ".txt" ;
StreamWriter^ sw = File::CreateText( path );
try
{
sw->WriteLine("");
}
finally
{
if ( sw )
delete (IDisposable^)sw;
}
}
};
FIXED CODE:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
NewPart ^newpart = gcnew NewPart();
newpart->ShowDialog();
this->Close();
String^ fileName = textBox1->Text;
String^ filetype = ".xml";
String^ path = L"C:\\;
String^ fullName = path + fileName + filetype;
StreamWriter^ sw = File::CreateText(fullName);
try
{
sw->WriteLine("<?xml version= \"1.0\" standalone=\"yes\"?>");
sw->WriteLine("<macdata");
sw->WriteLine("</macdata>");
}
finally
{
if ( sw )
delete (IDisposable^)sw;
}
}
};
}
Replace textBox1 with actual TextBox name from your form.
Edit. Regarding your second question, look at this code:
int main(array ^args) { String^ fileName = L"file.txt"; String^ path = L"C:\\"; String^ fullName = path + fileName; Console::WriteLine(fullName); return 0; }