Advertisement

04.01.2008 at 07:37AM PDT, ID: 23285883
[x]
Attachment Details

Get Text from Edit Control and concatenate in file path string

Asked by pat_cunningham in Microsoft Visual C++.Net

Not familiar with Visual C++.  This code compiles ok but I get a memory exception error when the GetDlgItemText function tries to execute.  I am trying to get the text entered by the user and use it to rename an image file.  Any help is appreciated.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
void CMainDlg::OnRead2()
{
	int result;
	CString new_file_name[10];
	GetDlgItemText(IDC_TEXTBOX, new_name[10]);
	CString old_path_name = "C:\\OldLocation\\old_file_name.jpg";
	CString new_path_name = "C:\\NewLocation\\" + new_file_name[10] + ".jpg";
 
	int iRet;
	iRet = AfxMessageBox("Save the new file with the name = " + new_file_name[10] + "?",MB_OKCANCEL);
	if(iRet == IDOK)
	{
		result= rename( old_path_name , new_path_name );
		if (result != 0 )
		{
			AfxMessageBox("Cannot rename file.  File may already exists on C drive.");
		}
		else
		{
			AfxMessageBox("The new file " + new_file_name[10] + " has been saved to C.");
		}
	}
 
}
[+][-]04.01.2008 at 07:44AM PDT, ID: 21254418

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Sign Up Now!
Solution Provided By: AndyAinscow
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.01.2008 at 10:58AM PDT, ID: 21256437

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628