[RESOLVED] Delete Undeletable Folder
I have created a folder named "CON" via command prompt. It is a reserve word so you can't delete it in windows but can be deleted in CMD. Is there a way to delete it programatically using API perhaps?
I've been thinking of using it in my little project. :D Thank you!
Re: Delete Undeletable Folder
Quote:
Originally Posted by zynder
I have created a folder named "CON" via command prompt.
How you've created a CON folder ? :eek:
Normally you get an error saying "The directory name is invalid."
Re: Delete Undeletable Folder
Yes it can be done via command prompt.
C:\>mkdir \\.\c:\con
Try deleting it in windows and will get an error.
To delete use
C:\>rmdir \\.\c:\con
Is it possible using Vb6 or API?
Re: Delete Undeletable Folder
shell "cmd /c rmdir \\.\c:\con"
Re: Delete Undeletable Folder
It's the same thing. Mr. Mac. I want an API version. No shelling. Is there a workaround with this?
Re: Delete Undeletable Folder
Quick question: What's wrong with SHELL?
Re: Delete Undeletable Folder
There's nothing wrong. I looking for other ways otherwise I wouldnt be asking this quesion in the first place.
Re: Delete Undeletable Folder
CreateDirectory and RemoveDirectory.
Code:
Option Explicit
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
Dim Security As SECURITY_ATTRIBUTES
Dim Ret As Long
'Create a directory
Ret = CreateDirectory("\\.\D:\con", Security)
'If CreateDirectory returns 0, the function has failed
If Ret = 0 Then
MsgBox "Error : Couldn't create directory !", vbCritical + vbOKOnly
Else
MsgBox "Directory created"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox "Removing directory"
RemoveDirectory "\\.\D:\con"
End Sub
Re: Delete Undeletable Folder
Thanks a bunch iPrank but can you post it in a copy paste friendly code tags? :)
Quote:
You must spread some Reputation around before giving it to iPrank again.
Re: Delete Undeletable Folder
Quote:
Originally Posted by Mr.Mac
Quick question: What's wrong with SHELL?
Professors give you higher grades when you use API's!!:D
Re: Delete Undeletable Folder
Quote:
Originally Posted by zynder
Thanks a bunch iPrank but can you post it in a copy paste friendly code tags? :)
Done.
You can use my or MartinLiss's addins to copy [HIGHLIGHT] tagged code or use Opera ;)
Re: Delete Undeletable Folder
Problem solved! Cheers to all of you! iPrank your the man.