Question : Error received - "Access to the path 'C:\System Volume Information' is denied." - when trying to search for a file

I'm trying to create a Sub routine in Vb.Net using a Button click event to search for a specific file on my entire C:\ Volume. When I run it and it hits this line of code, "files = Directory.GetFiles("C:\", TextBox1.Text, SearchOption.AllDirectories)", I receive the following error. --> "Access to the path 'C:\System Volume Information' is denied."
Not sure if I should reset the ACL Permissions using ATTRIB during the routine or what.

This is a small routine and I just want to sure for the file "Desktop.ini" on my XP Pro machine because our company has encryption enforced, and for whatever reason, this stupid file is in a number of directories.
Therefore, I can't copy data from one hard drive to another (from another machine, not the original one) one.

Thanks for any help anyone can provide.
Wallace
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim file As String
        Dim files() As String
        files = Directory.GetFiles("C:\", TextBox1.Text, SearchOption.AllDirectories)
        For Each file In files
            My.Computer.FileSystem.DeleteFile(TextBox1.Text)
        Next
    End Sub

Answer : Error received - "Access to the path 'C:\System Volume Information' is denied." - when trying to search for a file

>> I just want to delete the desktop.ini file

Then you have to do something like this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
    ''' 
    ''' Deletes a specific file on directory/drive
    ''' 
    ''' Root dirrectory to start check
    ''' File to delete
    ''' 
    ''' 
    Function DeleteFile(ByVal strRootPath As String, ByVal strFileToDelete As String) As Integer
        Try
 
            Dim x As Integer = 0
 
            Dim FullDir() As String = IO.Directory.GetDirectories(strRootPath)
            For Each Dir As String In FullDir
                If Dir <> (strRootPath & "System Volume Information") Then
                    Dim FullFiles() As String = IO.Directory.GetFiles(Dir, strFileToDelete, SearchOption.AllDirectories)
                    For Each File As String In FullFiles
                        My.Computer.FileSystem.DeleteFile(File)
                        x += 1
                    Next
                End If
            Next
            Return x
 
        Catch ex As Exception
            Return 0
        End Try
 
    End Function
 
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show(DeleteFile("c:\", "abc.ini"))
    End Sub
Random Solutions  
 
programming4us programming4us