Drag and drop
1)In my application i have added the feature of drag and drop...when i drop a folder, containing files. files are not uploading to a server only folders are creating...the coding is as follows...
//In class A
void CFtpListView::OnDropFiles(HDROP hDropInfo)
{
char szFileName[_MAX_PATH];
CTransferManagerDlg* m_pTransferManager;
// determine how many files are dropped
UINT nCount = DragQueryFile(hDropInfo, -1, NULL, 0);
for(UINT i=0; i < nCount; i++)
{
// get the filename
DragQueryFile(hDropInfo, i, szFileName, _MAX_PATH);
CString strDropName = szFileName;
// check if it a directory
if ((GetFileAttributes(szFileName) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
{
// enumerate directory structure and add everything to queue
CStringArray strFileNames;
CString strFileName, strSize, strPath, strDestination,strDestination1;
RecursiveFileList(szFileName, strFileNames);
// queue all found files
for (int i = 0; i < strFileNames.GetSize(); i++)
{
AfxExtractSubString(strFileName, strFileNames.GetAt(i), 0, '|');
AfxExtractSubString(strPath, strFileNames.GetAt(i), 1, '|');
// fix path
int nPos = strDropName.ReverseFind('\\');
if (nPos != -1)
{
strDropName = strDropName.Left(nPos+1);
}
strDestination = strPath;
int nLength = strDropName.GetLength();
strDestination = strDestination.Mid(nLength);
strDestination.Replace('\\', '/');
strDestination1=strDestination + "/" + strFileName;
((CMainFrame *)AfxGetMainWnd())->UploadFile(strPath + "\\" + strFileName,strDestination1);
//m_pTransferManager->QueueUpload(
}
}
else
{
int nPos = strDropName.ReverseFind('\\');
if (nPos != -1)
{
((CMainFrame *)AfxGetMainWnd())->UploadFile(strDropName, strDropName.Mid(nPos+1));
}
}
}
CListView::OnDropFiles(hDropInfo);
}
In Class B
Im opening a file like this...
CInternetFile* pInternetFile = m_pFtpConnection->OpenFile(dest, GENERIC_WRITE);
But the openfile function is returning NULL when it enounters an file to be uploaded to a server which is inside a folder..

