Hi Simon Jefferies
try this code it seems to work i tried this
SHFILEOPSTRUCT s ;
::ZeroMemory ( &s, sizeof ( s ) ) ; // Initialize the structure
CString f = "C:\\MyFolder" ;
//CString t = "D:\\" ;
char from [ MAX_PATH ], to [ MAX_PATH ] ; // buffer used to copy source and
target path
strcpy ( from, f ) ;
int l = f.GetLength( ) ;
from[l+1] = '\0' ;
//strcpy ( to, t ) ;
//l = t.GetLength( ) ;
//to[l+1] = '\0' ;
// Set the values in structure
s.hwnd = this -> m_hWnd ;
s.wFunc = FO_DELETE ;
s.pFrom = ( LPCTSTR ) from ;
//s.pTo = ( LPCTSTR ) to ;
s.fFlags = FOF_SIMPLEPROGRESS ;
s.lpszProgressTitle = "Moving files..." ;
::SHFileOperation ( &s ) ;
----
Deepak
"Simon Jefferies" <je*************@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hello,
I am trying to delete a file using SHFileOperation, but get the error code
1026.
Code snippet:
SHFILEOPSTRUCT fo;
ZeroMemory(&fo, sizeof(fo));
fo.fFlags = FOF_ALLOWUNDO | FOF_FILESONLY;
fo.wFunc = FO_DELETE; // delete contents of this folder
fo.pFrom = szFilename;
int nSuccessCode = SHFileOperation(&fo);
The file does exist and have tried with other files/paths etc but these do
not work.
Any ideas?
TIA
Simon Jefferies