Hi to all!
Is there some API that can copy all files from one directory to another?
Thanks,
Mike
Is there some API that can copy all files from one directory to another?
Thanks,
Mike
SHFileOperation with a *.* wildcard should work.
Mike,
No
donkey,
"SHFileOperation
You should use fully-qualified path names with this function.
Using it with relative path names is not thread-safe."
and
"SHFILEOPSTRUCT
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." from MSDN
Regards,
Lingo
No
donkey,
"SHFileOperation
You should use fully-qualified path names with this function.
Using it with relative path names is not thread-safe."
and
"SHFILEOPSTRUCT
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." from MSDN
Regards,
Lingo
Mmmm... tried this and it works fine on Win2K:
CopyFolder proc
LOCAL sfo :SHFILEOPSTRUCT
LOCAL sfoabort :DWORD
.data
olddir db "C:\TestDir\*.*",0
newdir db "C:\TestDir2",0
.code
mov eax,hDlg
mov sfo.hwnd,eax
mov sfo.wFunc,FO_COPY
mov eax,OFFSET olddir
mov sfo.pFrom,eax
mov eax,OFFSET newdir
mov sfo.pTo,eax
mov sfo.fFlags,FOF_FILESONLY or FOF_NOERRORUI
lea eax,sfoabort
mov sfo.fAnyOperationsAborted,eax
mov sfo.hNameMappings,NULL
mov sfo.lpszProgressTitle,NULL
invoke SHFileOperation,ADDR sfo
ret
CopyFolder endp
Mike,
The answer is Yes, SHFileOperation will do what you want.
Lingo,
Fully qualified paths are not *required* you can use a relative path if you like. The reason they are not thread safe is that another thread may change the current directory during a copy operation. If you do not supply a fully qualified path the function will use the folder specifed in SetCurrentDirectory. Since there is no need to specify the destination file name if you are not renaming it, there is no need to supply a list of file names, just the wild card will do.
The answer is Yes, SHFileOperation will do what you want.
Lingo,
Fully qualified paths are not *required* you can use a relative path if you like. The reason they are not thread safe is that another thread may change the current directory during a copy operation. If you do not supply a fully qualified path the function will use the folder specifed in SetCurrentDirectory. Since there is no need to specify the destination file name if you are not renaming it, there is no need to supply a list of file names, just the wild card will do.
If the pFrom or pTo members are unqualified names, the current directories are taken from the global current drive and directory settings as managed by the GetCurrentDirectory and SetCurrentDirectory functions.
Thank you, donkey!
Your answer is excelent!. All works properly and not only under 2k, but under 9x too.
Mike
Your answer is excelent!. All works properly and not only under 2k, but under 9x too.
Mike