Results 1 to 10 of 10

Thread: (Resolved)...Delete a shared file or folders (Win9x)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137

    (Resolved)...Delete a shared file or folders (Win9x)

    Hello,

    Can anybody help me on how to delete a file or folder on the network using Windows 9x. I tried with the code below but it did not work. It works perfectly on WinNT or Win2k.


    Code:

    Dim fs, f, f1, sf
    Dim strRemoteFolderPath as String

    strRemoteFolderPath = txtPathName.Text

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(strRemoteFolderPath)
    Set sf = f.Files

    For Each f1 In sf
    if f1.Name = txtFileName.Text then
    f1.Delete True
    end if
    next

    'End code


    Any help will be appreciated

    vbBoy
    Last edited by vbBoy; May 28th, 2002 at 01:34 AM.

  2. #2
    Member
    Join Date
    Nov 2000
    Posts
    51
    dunno, but
    Code:
    Kill "\\anything\\dir1\\myfile.txt"
    FileSystem.RmDir "\\anything\\dir1"
    might work.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137
    Thanks for reply Quix..

    I did try that also. but it did not work.

    vbBoy

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137
    I prefer using the FSO because if the file is flagged read only, the "Kill" or "RmDir" command will return an error.

  5. #5
    Member
    Join Date
    Nov 2000
    Posts
    51

    how about the api-functions?

    Code:
    Public Declare Function RemoveDirectory Lib "kernel32" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Long
    
    Public Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137
    I will try it when I get home. I don't have a win9x computer here.


    thanks

    vbBOy

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137
    Quix.....

    It still does not work on Windows 9x computers. It works only on files and folders located on the local computer and not on files and folders located on the network.

    For NT/2K it works fine for local or network files. Do you have any other ideas for me?

    Thanks


    vbBoy

  8. #8
    Member essaar's Avatar
    Join Date
    Mar 2002
    Location
    India
    Posts
    40
    Your code works fine on my WIN98 SE machines.

    HAHK is the remote PC's name.

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim fs, f, f1, sf
    3. Dim strRemoteFolderPath As String
    4.  
    5. strRemoteFolderPath = "\\Hahk\d\todel"
    6.  
    7. Set fs = CreateObject("Scripting.FileSystemObject")
    8. Set f = fs.GetFolder(strRemoteFolderPath)
    9. Set sf = f.Files
    10.  
    11. For Each f1 In sf
    12.     If f1.Name <> "" Then
    13.         f1.Delete True
    14.     End If
    15. Next
    16.  
    17. End Sub

    A picture is worth a thousand words...and uses up a thousand times the memory.
    - essaar

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137
    Thanks for all your replies Guys...

    I have resolved it. It was an access rights problem.


    vbBoy

  10. #10
    New Member
    Join Date
    Jan 2006
    Posts
    8

    Re: (Resolved)...Delete a shared file or folders (Win9x)

    Quote Originally Posted by vbBoy
    I prefer using the FSO because if the file is flagged read only, the "Kill" or "RmDir" command will return an error.
    This was my problem! I didn't know that the read-only attribute was making kill return an error of 75 - File/path access error.
    If going that route and wanting to use Kill, first do SetAttr(strFile, vbNormal)

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