|
-
May 26th, 2007, 09:07 AM
#1
Thread Starter
Frenzied Member
[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. Thank you!
-
May 26th, 2007, 09:17 AM
#2
Re: Delete Undeletable Folder
 Originally Posted by zynder
I have created a folder named "CON" via command prompt.
How you've created a CON folder ? 
Normally you get an error saying "The directory name is invalid."
-
May 26th, 2007, 09:21 AM
#3
Thread Starter
Frenzied Member
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?
-
May 26th, 2007, 09:47 AM
#4
Hyperactive Member
Re: Delete Undeletable Folder
shell "cmd /c rmdir \\.\c:\con"
Last edited by Mr.Mac; May 26th, 2007 at 09:54 AM.
Reason: Forgot cmd /
-
May 26th, 2007, 10:12 AM
#5
Thread Starter
Frenzied Member
Re: Delete Undeletable Folder
It's the same thing. Mr. Mac. I want an API version. No shelling. Is there a workaround with this?
-
May 26th, 2007, 10:23 AM
#6
Hyperactive Member
Re: Delete Undeletable Folder
Quick question: What's wrong with SHELL?
-
May 26th, 2007, 10:33 AM
#7
Thread Starter
Frenzied Member
Re: Delete Undeletable Folder
There's nothing wrong. I looking for other ways otherwise I wouldnt be asking this quesion in the first place.
-
May 26th, 2007, 10:41 AM
#8
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
Last edited by iPrank; May 26th, 2007 at 10:46 AM.
-
May 26th, 2007, 10:45 AM
#9
Thread Starter
Frenzied Member
Re: Delete Undeletable Folder
Thanks a bunch iPrank but can you post it in a copy paste friendly code tags? 
You must spread some Reputation around before giving it to iPrank again.
-
May 26th, 2007, 10:46 AM
#10
Lively Member
Re: Delete Undeletable Folder
 Originally Posted by Mr.Mac
Quick question: What's wrong with SHELL?
Professors give you higher grades when you use API's!!
-
May 26th, 2007, 10:48 AM
#11
Re: Delete Undeletable Folder
 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
-
May 26th, 2007, 10:50 AM
#12
Thread Starter
Frenzied Member
Re: Delete Undeletable Folder
Problem solved! Cheers to all of you! iPrank your the man.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|