copyfile
fold,fnew:pchar;
strpcopy(fold,'c:\11212.txt');
strpcopy(fnew,'c:\1.txt');copyfile(fold,fnew,true);he CopyFile function copies an existing file to a new file. BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
ParameterslpExistingFileNamePoints to a null-terminated string that specifies the name of an existing file. lpNewFileNamePoints to a null-terminated string that specifies the name of the new file. bFailIfExistsSpecifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. ResSecurity attributes for the existing file are not copied to the new file.
File attributes (FILE_ATTRIBUTE_*) for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For further information on file attributes, see CreateFile.See AlsoCreateFile, MoveFile
fold,fnew:pchar;
strpcopy(fold,'c:\11212.txt');
strpcopy(fnew,'c:\1.txt');copyfile(fold,fnew,true);he CopyFile function copies an existing file to a new file. BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
ParameterslpExistingFileNamePoints to a null-terminated string that specifies the name of an existing file. lpNewFileNamePoints to a null-terminated string that specifies the name of the new file. bFailIfExistsSpecifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. ResSecurity attributes for the existing file are not copied to the new file.
File attributes (FILE_ATTRIBUTE_*) for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For further information on file attributes, see CreateFile.See AlsoCreateFile, MoveFile
解决方案 »
- 如何用Pointer对象获取变量内存地址
- ADO与MySQL
- 有误删除文件经历的同志们进来一下!加散分!
- DBGrid
- delphi中怎样拆分一个string啊??
- Delphi可不可以实现与C中宏函数相同的功能,实现原理?
- 想走不敢
- 请教各位大哥:database控件中的alisename和databasename有何异同,与query的databasename有何关系???
- 如何实现100微秒的延迟
- 应该把他定义成什么数据类型?
- 为了实现检查网络上是否还有打开的计算机,我想编写程序通过ping命令来实现.但不知道怎样实现.或是有什么其他的好办法解决??敬请各位相告.请详细点!!!!
- 如何控制针式打印机的走纸?
The following sample console application illustrates the use of SHFileOperation to copy files from one directory to another. The source and destination directories, C:\My_Docs and C:\My_Docs2, are hard-coded into the application for simplicity.#include <shlobj.h>
#include <shlwapi.h>main()
{
IShellFolder *psfDeskTop = NULL;
IShellFolder *psfDocFiles = NULL;
IMalloc *pMalloc = NULL;
LPITEMIDLIST pidlDocFiles = NULL;
LPITEMIDLIST pidlItems = NULL;
IEnumIDList *ppenum = NULL;
SHFILEOPSTRUCT sfo;
STRRET strDispName;
TCHAR szParseName[MAX_PATH];
TCHAR szSourceFiles[256];
int i;
int iBufPos = 0;
ULONG chEaten;
ULONG celtFetched;
HRESULT hr; pzSourceFiles[0] = '\0';
hr = SHGetMalloc(&pMalloc);
hr = SHGetDesktopFolder(&psfDeskTop); hr = psfDeskTop->ParseDisplayName(NULL, NULL, L"c:\\My_Docs",
&chEaten, &pidlDocFiles, NULL);
hr = psfDeskTop->BindToObject(pidlDocFiles, NULL, IID_IShellFolder,
(LPVOID *) &psfDocFiles);
hr = psfDeskTop->Release(); hr = psfDocFiles->EnumObjects(NULL,SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
&ppenum); while( (hr = ppenum->Next(1,&pidlItems, &celtFetched)) == S_OK
&& (celtFetched) == 1)
{
psfDocFiles->GetDisplayNameOf(pidlItems, SHGDN_FORPARSING,
&strDispName);
StrRetToBuf(&strDispName, pidlItems, szParseName, MAX_PATH);
for(i=0;i<=lstrlen(szParseName); i++)
{
szSourceFiles[iBufPos++] = szParseName[i];
}
pMalloc->Free(pidlItems);
}
ppenum->Release();
szSourceFiles[iBufPos] = '\0'; sfo.hwnd = NULL;
sfo.wFunc = FO_COPY;
sfo.pFrom = szSourceFiles;
sfo.pTo = "c:\\My_Docs2\0";
sfo.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR; hr = SHFileOperation(&sfo);
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, (LPCVOID) "c:\My_Docs2", 0); pMalloc->Free(pidlDocFiles);
psfDocFiles->Release(); return 0;
}