/zh-cn/docs/commands/FileDelete.htm

https://github.com/wyagd001/wyagd001.github.io · HTML · 44 lines · 36 code · 8 blank · 0 comment · 0 complexity · ced820fa920eb6ef4ff67176e39169e9 MD5 · raw file

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>FileDelete | AutoHotkey</title>
  5. <meta name="description" content="The FileDelete command deletes one or more files." />
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  9. <script src="../static/content.js" type="text/javascript"></script>
  10. <script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
  11. </head>
  12. <body>
  13. <h1>FileDelete</h1>
  14. <p>删除一个或多个文件.</p>
  15. <pre class="Syntax"><span class="func">FileDelete</span>, FilePattern</pre>
  16. <h2 id="Parameters">参数</h2>
  17. <dl>
  18. <dt>FilePattern</dt>
  19. <dd><p>单个文件的名称或通配符模式, 例如 <code>C:\Temp\*.tmp</code>. 如果未指定绝对路径, 则假定 <em>FilePattern</em> <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a>.</p>
  20. <p>要删除整个文件夹及其所有子文件夹和文件, 请使用 <a href="FileRemoveDir.htm">FileRemoveDir</a>.</p></dd>
  21. </dl>
  22. <h2 id="Error_Handling">错误处理</h2>
  23. <p><span class="ver">[v1.1.04+]</span>: 此命令失败时会抛出异常. 想了解更多信息, 请参阅<a href="Catch.htm#RuntimeErrors">运行时错误</a>.</p>
  24. <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> 被设置为删除失败的文件数, 否则为 0. 删除像 <code>*.tmp</code> 这样的通配符模式即使它不匹配任何文件也被视为是成功的; 因此 ErrorLevel 被置为 0.</p>
  25. <p>如果找到了文件, <a href="../Variables.htm#LastError">A_LastError</a> 会被设置为 0() 或最近一次操作失败时调用操作系统 GetLastError() 函数的结果. 否则 A_LastError 包含了没有找到文件原因的错误码.</p>
  26. <h2 id="Remarks">备注</h2>
  27. <p>要删除只读文件, 请首先移除它的只读属性. 例如: <code><a href="FileSetAttrib.htm">FileSetAttrib</a>, -R, C:\My File.txt</code>.</p>
  28. <h2 id="Related">相关</h2>
  29. <p><a href="FileRecycle.htm">FileRecycle</a>, <a href="FileRemoveDir.htm">FileRemoveDir</a>, <a href="FileCopy.htm">FileCopy</a>, <a href="FileMove.htm">FileMove</a></p>
  30. <h2 id="Examples">示例</h2>
  31. <div class="ex" id="ExBasic">
  32. <p><a class="ex_number" href="#ExBasic"></a> 删除目录中的所有 .tmp 文件.</p>
  33. <pre>FileDelete, C:\temp files\*.tmp</pre>
  34. </div>
  35. </body>
  36. </html>