Click to See Complete Forum and Search --> : HELP!


Sophie
April 20th, 1999, 05:46 PM
Hi,

What I'm trying to accomplish is to add "Lavac\Lecons" to my m_questPath before I start anything.
So basically the user will type a path where they want to copy. For example :
C:\temp and from there I add Lavac\Lecons and copy all folders and files underneath Lecons. Right now the code will create the C:\temp\Lavac\Lecons but will copy L0000001 underneath C:\temp.

Can someone help me?

CString CDlgQuestionPath::GetQuesPath()
{
return m_quesPath;
}


void CDlgQuestionPath::OnChangeQuesPath()
{
UpdateData(TRUE); //Will update all existing variables.
CString quesPath = GetQuesPath();
Path path(ToString(quesPath));
path.AppendToPath("Lavac\\Lecons");

}

void CDlgQuestionPath::OnQuesBrowse()
{
CString quesPath = GetQuesPath();
CString strTitle;
strTitle.LoadString(IDS_TITLE);
CSelectFolder dlg(quesPath,strTitle, this) ;
if(dlg.DoModal() == IDOK)
{
m_quesPath = dlg.GetFolder();
UpdateData(FALSE);
}

}

void CDlgQuestionPath::OnOK()
{
bool canExit = true;
UpdateData(TRUE); //Will update all existing variables.
CString destPath = GetQuesPath();
Path path(ToString(destPath));
if (!path.IsDirect()){
int iResponse = AfxMessageBox(IDS_WARN_NODIRECTORYEXIST, MB_YESNO|MB_ICONQUESTION);
if(iResponse == IDYES) {
Directory dir(ToString(destPath));
dir.AppendToPath("Lavac\\Lecons");
if(dir.Create() == false){
AfxMessageBox(IDS_WARN_DIRCREATIONFAILED, MB_OK|MB_ICONWARNING);
canExit = false;
}

}
else{
canExit = false;
}
}
else{
path.AppendToPath("Lavac\\Lecons");
}
if(canExit == true)
CDialog::OnOK();
}
Path &Path::AppendToPath( const string &base)
{
if( name.length() == 0)
SetPath( base);
else{
AddPathSeparator();
if( base[ 0] == PathSep)
name.append( base, 1, base.length() - 1);
else
name.append( base, 0, base.length());

name= FullPath( name);
}
return *this;
}

Safai Ma
April 20th, 1999, 10:21 PM
First off, the function OnChangeQuesPath is *ONLY* modifing *LOCAL* variables so it doesn't change your member variable m_quesPath.

Next, check the code that actually copy L0000001 file to make sure it uses the path returned from this dialog.

If all is fine, then you may want to post the code that copies the file as the code that you posted here is just for asking the user for the directory path and creating the directory, this will allow us to help you figure out what's wrong.

Safai