Home > Software engineering >  For VB under a specified folder files and delete methods
For VB under a specified folder files and delete methods

Time:11-02

For example has known path C: \ Users \... Under a file in the file 123. TXT file, if search to this file and delete (delete no into the recycle bin) thank you

CodePudding user response:

Delete might involve under permission problems thank you for your help very urgent

CodePudding user response:

 command1_click () 
Dim f as string
D="C: \ Users \ 123. TXT"
If dir (f) & lt; & gt;" "Then
Kill f
End the if

CodePudding user response:

We might want to use.

CodePudding user response:

If your problem is deleting files, you can use vb kill statements for file deletion,
If your problem is to search the files in the folder, you can use the dir function recursive method in the vb implementation file directory search, of course, the simple point can also be used with FileListBox DirListBox controls or fso or wmi object,
If your problem is a directory or file permissions, it will have to see if your current running program permissions have sufficient privileges to modify the directory or file, but also to see your partition table is NTFS can determine whether need permissions, if is FAT32, can consider this problem, it is not necessary to for NTFS partition, if you have administrator privileges, so usually is able to operate most of the directory or file, of course, if the directory or file is used by the system or lock, you can't delete, in addition to this kind of circumstance, is your users or groups of users is not set to the directory or file, so have no right to operation, if this is the case can be
The Shell "CMD/C Cacls" & amp; Directory address & amp; "/T/E/C/G" & amp; The user account & amp; ":" F, vbNormalFocus
Will you permissions to the target directory or the safety of the target file, after you have the right to operate the directory or file.
  • Related