大家知道怎样移动、删除整个目录及怎样给一个目录改名吗? (50分)

  • 主题发起人 主题发起人 chemstar
  • 开始时间 开始时间
C

chemstar

Unregistered / Unconfirmed
GUEST, unregistred user!
大家知道怎样移动、删除整个目录及怎样给一个目录改名吗?
 
http://www.china-pub.com/computers/emook/0880/info.htm
 
妙极!<br>但是怎样给一个目录改名呢?
 
:liulg_bj, <br>但是我按他给出的方法好像不能用呀。
 
RenameFile(F:/ss/sss', 'F:/ss/ssss'); &nbsp;
 
to 来如风, <br>&nbsp; 谢谢!改名问题解决。<br> 复制和移动的问题我也自己解决了。用了一个函数:ShFileOperation。<br> 但是删除的时候怎么总是不行,大家用对这个函数有研究的吗?<br>
 
文件名要用#0格开,最后要有两个#0<br>附SHFILEOPSTRUCT得说明<br>SHFILEOPSTRUCT<br>Contains information that the SHFileOperation function uses to perform file operations. <br><br><br><br>typedef struct _SHFILEOPSTRUCT{ <br>&nbsp; &nbsp; HWND hwnd; <br>&nbsp; &nbsp; UINT wFunc; <br>&nbsp; &nbsp; LPCTSTR pFrom; <br>&nbsp; &nbsp; LPCTSTR pTo; <br>&nbsp; &nbsp; FILEOP_FLAGS fFlags; <br>&nbsp; &nbsp; BOOL fAnyOperationsAborted; <br>&nbsp; &nbsp; LPVOID hNameMappings; <br>&nbsp; &nbsp; LPCSTR lpszProgressTitle; <br>} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;<br>&nbsp;<br>Members<br>hwnd <br>Window handle to the dialog box to display information about the status of the file operation. <br>wFunc <br>Value that indicates which operation to perform. This member can be one of the following values: <br>FO_COPY <br>Copy the files specified in the pFrom member to the location specified in the pTo member. <br>FO_DELETE <br>Delete the files specified in pFrom. <br>FO_MOVE <br>Move the files specified in pFrom to the location specified in pTo. <br>FO_RENAME <br>Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead. <br>pFrom <br>Address of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard DOS wild cards, such as "*", are permitted in the filename 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. <br>pTo <br>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: <br>Wildcard characters are not supported. <br>Copy and Move operations can specify destination directories that do not exist and the system will attempt to create them. The system normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMDIR flag in fFiles. <br>For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES. <br>Pack multiple names into the string in the same way as for pFrom. <br>Use only fully-qualified path names. Using relative pathnames will have unpredictable results. <br>fFlags <br>Flags that control the file operation. This member can take a combination of the following flags: Flag Description <br>FOF_ALLOWUNDO &nbsp;Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored. &nbsp;<br>FOF_FILESONLY &nbsp;Perform the operation on files only if a wildcard file name (*.*) is specified. &nbsp;<br>FOF_MULTIDESTFILES &nbsp;The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited. &nbsp;<br>FOF_NOCONFIRMATION &nbsp;Respond with "Yes to All" for any dialog box that is displayed. &nbsp;<br>FOF_NOCONFIRMMKDIR &nbsp;Do not confirm the creation of a new directory if the operation requires one to be created. &nbsp;<br>FOF_NO_CONNECTED_ELEMENTS Version 5.0. Do not move connected files as a group. Only move the specified files. &nbsp;<br>FOF_NOCOPYSECURITYATTRIBS Version 4.71. Do not copy the security attributes of the file. <br>FOF_NOERRORUI &nbsp;Do not display a user interface if an error occurs. &nbsp;<br>FOF_NORECURSION Only operate in the local directory. Don't operate recursively into subdirectories. <br>FOF_RENAMEONCOLLISION &nbsp;Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists. &nbsp;<br>FOF_SILENT &nbsp;Do not display a progress dialog box. &nbsp;<br>FOF_SIMPLEPROGRESS &nbsp;Display a progress dialog box but do not show the file names. &nbsp;<br>FOF_WANTMAPPINGHANDLE &nbsp;If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member. <br>FOF_WANTNUKEWARNING Version 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION. <br><br>fAnyOperationsAborted <br>Value that receives TRUE if the user aborted any file operations before they were completed, or FALSE otherwise. <br>hNameMappings <br>A handle to a name mapping object containing the old and new names of the renamed files. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. Treat hNameMappings as a pointer to a structure whose first member is an INT value, followed by an array of SHNAMEMAPPING structures. The INT value will be set to the number of structures in the array. Each SHNAMEMAPPING structure will contain the old and new path name for one of the renamed files. <br>Note: The handle must be freed with SHFreeNameMappings.<br><br>lpszProgressTitle <br>Address of a string to use as the title of a progress dialog box. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag. <br>Remarks<br>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. <br><br>If pFrom is set to a filename, deleting the file with FO_DELETE will not move it to the Recycle Bin, even if the FOF_ALLOWUNDO flag is set. You must use a full pathname.<br><br>Requirements <br>&nbsp; Version 4.00 and later of Shell32.dll<br><br>&nbsp; Windows NT/2000: Requires Windows NT 4.0 or later. <br>&nbsp; Windows 95/98: Requires Windows 95 or later. <br>&nbsp; Header: Declared in shellapi.h.
 
后退
顶部