如何用程序来Delete Copy Move Rename File/Directory

2016-02-19 16:52 26 1 收藏

想不想get新技能酷炫一下,今天图老师小编就跟大家分享个简单的如何用程序来Delete Copy Move Rename File/Directory教程,一起来看看吧!超容易上手~

【 tulaoshi.com - 编程语言 】

  

Private Type SHFILEOPSTRUCT    hwnd As Long    wFunc As Long    pFrom As String    pTo As String    fFlags As Integer    fAnyOperationsAborted As Long    hNameMappings As Long    lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESSEnd Type'wFunc 的设定值'FO_COPY   Copies the files specified by pFrom to the location specified by pTo.'FO_DELETE  Deletes the files specified by pFrom (pTo is ignored).'FO_MOVE   Moves the files specified by pFrom to the location specified by pTo.'FO_RENAME  Renames the files specified by pFrom.'fFlag的设定'FOF_ALLOWUNDO      Preserves undo information, if possible.'FOF_FILESONLY      Performs the operation only on files if a wildcard filename'            (*.*) is specified.'FOF_MULTIDESTFILES   Indicates that the pTo member specifies multiple destination'            files (one for each source file) rather than one directory where'            all source files are to be deposited.'FOF_NOCONFIRMATION   Responds with "yes to all" for any dialog box that is displayed.'FOF_NOCONFIRMMKDIR   Does not confirm the creation of a new directory if'            the operation requires one to be created.'FOF_RENAMEONCOLLISION  Gives the file being operated on a new name (such as'            "Copy #1 of...") in a move, copy, or rename operation'            if a file of the target name already exists.'FOF_SILENT       Does not display a progress dialog box.'FOF_SIMPLEPROGRESS   Displays a progress dialog box, but does not show the'            filenames.'FOF_WANTMAPPINGHANDLE  Fills in the hNameMappings member. The handle must be'            freed by using the SHFreeNameMappings function.Const FO_MOVE = &H1Const FO_COPY = &H2Const FO_DELETE = &H3Const FOF_NOCONFIRMATION = &H10Const FOF_NOCONFIRMMKDIR = &H200Const FOF_ALLOWUNDO = &H40Const FOF_SILENT = &H4Private Declare Function SHFileOperation Lib "shell32.dll" Alias _        "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long'删除 test目录及其底下的子目录到资源回收桶Private Sub Command1_Click()  Dim SHFileOp As SHFILEOPSTRUCT  SHFileOp.wFunc = FO_DELETE  SHFileOp.pFrom = "c:test" + Chr(0)  '不出现档案删除的动态AVI,且不Confirm  SHFileOp.fFlags = FOF_SILENT + FOF_ALLOWUNDO + FOF_NOCONFIRMATION  '若没有 FOF_ALLOWUNDO 则不会到资源回收桶  Call SHFileOperation(SHFileOp)End Sub'同时删除多档到资源回收桶Private Sub Command2_Click()  Dim SHFileOp As SHFILEOPSTRUCT  Dim Files As String  'Files = "c:test.txt" + Chr(0)  Files = "c:test1.txt" + Chr(0) + "c:test2.txt" + Chr(0) + _      "c:test3.txt" + Chr(0)  SHFileOp.wFunc = FO_DELETE  SHFileOp.pFrom = Files  '删至资源回收桶,且不Confirm  SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION  Call SHFileOperation(SHFileOp)End Sub'将 c:temp 整个目录复制到 c:temp2Private Sub Command3_Click()  Dim SHFileOp As SHFILEOPSTRUCT  SHFileOp.wFunc = FO_COPY  SHFileOp.pFrom = "c:temp*.*"  SHFileOp.pTo = "c:temp2*.*"  SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR  Call SHFileOperation(SHFileOp)End Sub'将 c:test4.txt 快速移到 c:temp 目录Private Sub Command4_Click()  Dim SHFileOp As SHFILEOPSTRUCT  SHFileOp.wFunc = FO_MOVE  SHFileOp.pFrom = "c:test4.txt" + Chr(0)  SHFileOp.pTo = "c:temp"  SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION  Call SHFileOperation(SHFileOp)End Sub

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

来源:https://www.tulaoshi.com/n/20160219/1613402.html

延伸阅读
人们都希望自己的居所充满生机,在客厅摆一些绿色植物,不失为一种简便有效的方法。但这其中也有规则,否则将“费力不讨好”。 客厅如何装饰?如何用植物来装饰客厅 1、 最佳视点 。作为业主,摆置植物装饰无非是起到视觉上的享受。因此,植物在房间与家具中的具体摆放位置就影响到人们在客厅里对植物欣赏的程度。植物应摆...
不想另外安装第三方的发邮件组件,想直接利用MS的。 请问在VB里如何用MAPI来发送邮件(好像MAPI是OUTLOOK和OE自带有的吧),需要像在OE里发邮件一样先手工设置好发信帐号吗?能不能像JMAIL一样在发信时指定SMTP服务器及发信验证用户名和密码? 哪里有CDONTS发邮件的源码?我需要能指定发邮件的SMTP及认证用户名和密码的那个版本的,这就相当...
人们都希望自己的居所充满生机,在客厅摆一些绿色植物,不失为一种简便有效的方法。但这其中也有规则,否则将“费力不讨好”。 客厅如何装饰?如何用植物来装饰客厅 如何用植物来装饰客厅? 1、 最佳视点 。 作为业主,摆置植物装饰无非是起到视觉上的享受。因此,植物在房间与家具中的具体摆放位置就影响到...
标签: 孕前
排卵期内身体有哪些变化     排卵期内身体有哪些变化呢?女性排卵期内特征有很多比如容易动情分泌增多等等,下面我们就来详细给大家介绍下排卵期都有哪些变化,方便夫妻更好把握住受孕几率。     了解你的卵细胞     其实,女性的卵细胞与生俱来。当胎儿离开母体...
标签: 浏览器
如何用声音来操控IE浏览器 最近做字幕的时候发现一个通过声音控制IE浏览器的方法。本来是要制作字幕的,后来想想如果纯手工制作字幕的话那么效率肯定非常低,做为程序员,本能的想到了让计算机来帮忙。做字幕就是从声音识别出文字,然后在校对时间轴。很机械化的操作,非常适合计算机的来做。通过搜索很快找到了解决方案。使用Microsoft ...

经验教程

344

收藏

85
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部