Eugie » 11 ноя 2005, 13:41
Строковые значения для pFrom и pTo в SHFILEOPSTRUCT должны завершаться
парой символов NULL, цитата:
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
.....
pFrom
Address of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard Microsoft® MS-DOS® wild cards, such as "*", are permitted in the file-name position. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.
pTo
Address of a buffer to contain the name of the destination file or directory. This parameter must be set to NULL if it is not used. Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications.
.....
Вот так должно работать:
Код: Выделить всё
void CStrageDlg::OnBnClickedOk()
{
CFileFind finderfile;
LPCTSTR ptzFold = _T("Delthise\0");
CString strPath;
::SetCurrentDirectory(_T("C:\\"));
if(finderfile.FindFile("*.*",0))
{
while(finderfile.FindNextFile())
{
if(finderfile.IsDirectory())
{
CString strN = finderfile.GetFileName();
if(strN.CompareNoCase(ptzFold)==0)
{
strPath = finderfile.GetFilePath();
SetDlgItemText(IDC_STATIC, strPath);
SHFILEOPSTRUCT fa;
fa.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION;
fa.hNameMappings = NULL;
fa.hwnd = m_hWnd;
fa.pFrom = ptzFold;
fa.pTo = NULL;
fa.wFunc = FO_DELETE;
int nRes = ::SHFileOperation(&fa);
}
}
}
}
}
Строковые значения для pFrom и pTo в SHFILEOPSTRUCT должны завершаться [i]парой[/i] символов NULL, цитата:
[quote]
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
.....
pFrom
Address of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard Microsoft® MS-DOS® wild cards, such as "*", are permitted in the file-name position. [b]Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.[/b]
pTo
Address of a buffer to contain the name of the destination file or directory. This parameter must be set to NULL if it is not used. Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications.
.....
[/quote]
Вот так должно работать:
[code]
void CStrageDlg::OnBnClickedOk()
{
CFileFind finderfile;
LPCTSTR ptzFold = _T("Delthise\0");
CString strPath;
::SetCurrentDirectory(_T("C:\\"));
if(finderfile.FindFile("*.*",0))
{
while(finderfile.FindNextFile())
{
if(finderfile.IsDirectory())
{
CString strN = finderfile.GetFileName();
if(strN.CompareNoCase(ptzFold)==0)
{
strPath = finderfile.GetFilePath();
SetDlgItemText(IDC_STATIC, strPath);
SHFILEOPSTRUCT fa;
fa.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION;
fa.hNameMappings = NULL;
fa.hwnd = m_hWnd;
fa.pFrom = ptzFold;
fa.pTo = NULL;
fa.wFunc = FO_DELETE;
int nRes = ::SHFileOperation(&fa);
}
}
}
}
}
[/code]