网站首页  词典首页

请输入您要查询的函数:

 

术语 deletefile
释义 DeleteFile
语法:
C++
BOOL WINAPI DeleteFile(
__in LPCTSTR lpFileName
);
DeleteFile函数
删除现有文件。
作为一个要执行此操作的事务操作,请使用DeleteFileTransacted功能。
参数
lpFileName [in]
该文件的名称被删除。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零(0)。为了获得更多错误信息,调用GetLastError。
备注
如果一个应用程序试图删除文件不存在,DeleteFile函数失败,ERROR_FILE_NOT_FOUND。如果该文件是只读文件,该函数失败,ERROR_ACCESS_DENIED。
下面的列表列出了一些提示删除,删除或关闭文件:
要删除只读文件,首先您必须删除只读属性。
删除或重命名一个文件,您必须或者删除的文件的权限,或删除父目录儿童权限。
递归地删除目录中的文件,使用SHFileOperation函数。
要删除一个空目录,请使用RemoveDirectory函数。
要关闭一个打开的文件,请使用CloseHandle函数。
如果您设置了所有除删除和删除子,和访问控制列表的新文件(ACL)的访问目录中继承,那么您可以创建,而不能删除一个文件。但是,那么您可以创建一个文件,然后获取所有访问您在处理返回的时候您在创建该文件给您的要求。
如果您要求删除的时间创建文件的权限,您可以删除或重命名与该处理文件,但不与任何其他处理。有关更多信息,请参阅文件安全性和访问权限。
该DeleteFile函数失败如果应用程序试图删除一个文件,是正常开放的I / O或内存映射文件。
该DeleteFile函数标志着关闭时删除文件。因此,文件删除,不会发生,直到最后处理的文件关闭。在后续调用CreateFile打开文件失败,ERROR_ACCESS_DENIED。
符号链接行为
如果路径指向一个符号链接,符号链接被删除,而不是目标。要删除的目标,您必须调用CreateFile并指定FILE_FLAG_DELETE_ON_CLOSE。
实例
有关示例,请参阅锁定和解锁的文件字节范围。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesDeleteFileW(Unicode)和DeleteFileA(ANSI)的
参见
CloseHandle
CreateFile
DeleteFileTransacted
文件管理函数
符号链接
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==DeleteFile Function
Deletes an existing file.
To perform this operation as a transacted operation, use the DeleteFileTransacted function.
Syntax
C++
BOOL WINAPI DeleteFile(
__in LPCTSTR lpFileName
);
Parameters
lpFileName [in]
The name of the file to be deleted.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\\\?\\" to the path. For more information, see Naming a File .
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero (0). To get extended error information, call GetLastError .
Remarks
If an application attempts to delete a file that does not exist, the DeleteFile function fails with ERROR_FILE_NOT_FOUND. If the file is a read-only file, the function fails with ERROR_ACCESS_DENIED.
The following list identifies some tips for deleting, removing, or closing files:
To delete a read-only file, first you must remove the read-only attribute.
To delete or rename a file, you must have either delete permission on the file, or delete child permission in the parent directory.
To recursively delete the files in a directory, use the SHFileOperation function.
To remove an empty directory, use the RemoveDirectory function.
To close an open file, use the CloseHandle function.
If you set up a directory with all access except delete and delete child, and the access control lists (ACL) of new files are inherited, then you can create a file without being able to delete it. However, then you can create a file, and then get all the access you request on the handle that is returned to you at the time you create the file.
If you request delete permission at the time you create a file, you can delete or rename the file with that handle, but not with any other handle. For more information, see File Security and Access Rights .
The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file.
The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to CreateFile to open the file fail with ERROR_ACCESS_DENIED.
Symbolic link behavior—
If the path points to a symbolic link, the symbolic link is deleted, not the target. To delete a target, you must call CreateFile and specify FILE_FLAG_DELETE_ON_CLOSE.
Examples
For an example, see Locking and Unlocking Byte Ranges in Files .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesDeleteFileW (Unicode) and DeleteFileA (ANSI)
See Also
CloseHandle
CreateFile
DeleteFileTransacted
File Management Functions
Symbolic Links
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:20:56