Results 1 to 2 of 2

Thread: [RESOLVED] How to delete multiple files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Resolved [RESOLVED] How to delete multiple files

    I am trying to delete multiple files (.reg files) by using following code.

    My.Computer.FileSystem.DeleteFile(Environ("%systemdrive%") & "\*.reg")
    But its is generating an exception: Argument Exception was Unhandled.
    Illegal Characters in path.

    Any ideas what is going wrong.
    < advertising link removed by moderator >

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: How to delete multiple files

    Try this:
    Code:
      Try
                Dim regFiles() As String = System.IO.Directory.GetFiles(System.IO.Path.GetPathRoot(Environment.SystemDirectory), "*.reg")
                For Each regFile As String In regFiles
                    System.IO.File.Delete(regFile)
                Next
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

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