Results 1 to 12 of 12

Thread: [RESOLVED] Delete Undeletable Folder

  1. #1

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Resolved [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!

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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 ?
    Normally you get an error saying "The directory name is invalid."
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    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?

  4. #4
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    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 /

  5. #5

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Delete Undeletable Folder

    It's the same thing. Mr. Mac. I want an API version. No shelling. Is there a workaround with this?

  6. #6
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    Re: Delete Undeletable Folder

    Quick question: What's wrong with SHELL?

  7. #7

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Delete Undeletable Folder

    There's nothing wrong. I looking for other ways otherwise I wouldnt be asking this quesion in the first place.

  8. #8
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  9. #9

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    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.

  10. #10
    Lively Member
    Join Date
    Feb 2007
    Posts
    99

    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!!

  11. #11
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  12. #12

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    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
  •  



Click Here to Expand Forum to Full Width