Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DosCopy (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_DOSFILEMGR
USHORT DosCopy(pszSrc, pszDest, usOpt, ulReserved);
PSZ pszSrc; /* pointer to name of source file */
PSZ pszDest; /* pointer to name of target file */
USHORT usOpt; /* options */
ULONG ulReserved; /* must be zero */
The DosCopy function copies a file or subdirectory.
Parameter Description
────────────────────────────────────────────────────────────────────────────
pszSrc Points to the null-terminated string that specifies the file or
directory to copy. This string must be a valid MS OS/2 filename
and cannot contain wildcard characters.
pszDest Points to the null-terminated string that specifies the name of
the file, directory, or device to copy the value of pszSrc to.
This string must be a valid MS OS/2 filename and cannot contain
wildcard characters.
usOpt Specifies an option that can be used in the copy operation (it
is ignored if the destination is a device). This parameter can
be one of the following values:
Value Meaning
────────────────────────────────────────────────────────────────
DCPY_EXISTING Copy the source file to the destination file,
even if the destination file already exists. If
neither this option nor the DCPY_APPEND option is
specified, and the file exists, the value
ERROR_ACCESS_DENIED is returned.
DCPY_APPEND Append the data in the source file to the end of
the destination file. If the destination file
does not exist, a new file is created.
ulReserved Specifies a reserved value; must be zero.
Return Value
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
ERROR_ACCESS_DENIED
ERROR_DIRECTORY
ERROR_DRIVE_LOCKED
ERROR_FILE_NOT_FOUND
ERROR_FILENAME_EXCED_RANGE
ERROR_INSUFFICIENT_DISK_SPACE
ERROR_INVALID_PARAMETER
ERROR_NOT_DOS_DISK
ERROR_PATH_NOT_FOUND
ERROR_SHARING_BUFFER_EXCEEDED
ERROR_SHARING_VIOLATION
Comments
The DosCopy function can be used to copy individual files or entire
directories (including any subdirectories within the directory). The source
and destination files can be on different drives.
If an I/O error occurs when a file is being copied, the destination file is
deleted from the destination directory unless the DCPY_APPEND option is
specified. In this case, the destination file is restored to its original
size.
The DosCopy function copies the attributes of the source to the destination
file, except when appending to an existing file.
You cannot specify only the drive as the destination. You must give the path
on the drive where the file or directory is to be copied.
Example
This example copies the directory xyz from drive C, including its files and
subdirectories, to the root directory on drive A.
DosCopy("c:\\xyz", /* source directory */
"a:\\", /* destination directory */
DCPY_EXISTING, /* replaces existing files */
0L); /* reserved */
See Also
DosMove
♦