Results 1 to 6 of 6

Thread: A VB6 problem and strange thing

  1. #1
    Senior Member Falcon21's Avatar
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    252

    A VB6 problem and strange thing

    Hello, I am using WinXP Home. I am creating an application in VB6 and this is my problem:

    There is an sample folder with a file that I created.
    Let it be C:\folder\file.txt

    Then I run the command
    kill ("C:\folder\file.txt")
    followed by
    rmdir(C:\folder)

    The problem is that only the file is removed, the folder stays there. Also why is that all the folders in my computer is set to read-only attribute (when I check the properties of the folder, the Read-only attribute is checked and the box "appeared" to be disabled althought not).

    Then I code another app with only the rmdir command and it did remove the directory.

    Can anyone help me out...

  2. #2
    AntiOnline n00b
    Join Date
    Feb 2004
    Posts
    666
    Hi,

    works perfictly fine for me .................what is the error message you are getting ?.......and are you sure the folder is empty?

    I had like 5 -6 txt files in this test123 folder and this code delete all the files then the folder itse;f

    Private Sub Command1_Click()
    Kill ("C:\test123\*.txt")
    RmDir ("c:\test123")

    End Sub

  3. #3
    Senior Member Falcon21's Avatar
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    252
    Opps. I forgot to say that I have set the attributes of the file to Read-only, and the folder to all 4 attributes using setattr. Then when I want to remove the file and the folder, I first use setattr "C:\folder\file.txt", vbnormal followed by setattr "C:\folder\file.txt", vbnormal. Then I kill the file and remove the folder. The folder is named such that it include an "extension", such as folder.exe
    There is no other files in the folder other than the one that I already issued the kill command.
    There is an error while it is trying to remove the folder: Path/File access error
    After this error occured, the file is removed (which is correct), but the folder is still there when I checked...

  4. #4
    Senior Member Falcon21's Avatar
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    252
    I found a fix to my own problem :P
    After I "kill" the file, I use a do while loop...

    Do While Dir$(path of the file inside the folder) = vbNullString
    RmDir (folder path)
    Exit Do
    Loop

    Strangely, after I added this loop it solved my problem.

  5. #5
    Junior Member
    Join Date
    Feb 2005
    Posts
    2
    not srange, just ms

  6. #6
    Junior Member
    Join Date
    Feb 2005
    Posts
    2
    did u buy your copy of vb6, if u didnt plz can u tell me where u got it from, im desperate 2 try it. I have.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •