I am trying to retrieve all the names of the mp3 files from my hard drive, heres the full code, what i am facing is "Access to the path 'D:\System Volume Information' is denied." error, but i have changed the manifest file as below

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
 />

but still no luck any idea?

Heres the code

Dim filenames() As String = Directory.GetFiles(Cpath, "*.mp3", SearchOption.AllDirectories) 'this is where the D:\System Volume Information' is denied. error pops up
        Dim i As Integer
        Dim filename As String
        pgr1.Value += 2

        For i = 0 To filenames.Length - 1
            filename = Path.GetFileName(filenames(i))
            lst_cres.Items.Add(filename)
            pgr1.Value += 1
        Next i

        Label1.Text = "Total File Names : " & lst_cres.Items.Count

Recommended Answers

All 11 Replies

Try changin your requestedExecutionLevel to level="requireAdministrator". Once your program runs as Admin it should be able to access everything. Or alter your code to check real file info is coming back from your getFiles().

do you use Windows 7 OS?, I also encountered this problem previously, just run everything as an administrator will solve the problem

I have tried the code on a removable external hard disk with MP3 files the code works very good and as expected but when I try it on C drive and D drive it says Access Denied. I have changed requestedExecutionLevel to level="requireAdministrator too without any luck :( And yes i am using Vista and am running everything as admin

I have tried the code on a removable external hard disk with MP3 files the code works very good and as expected but when I try it on C drive and D drive it says Access Denied. I have changed requestedExecutionLevel to level="requireAdministrator too without any luck :( And yes i am using Vista and am running everything as admin

This is a system folder and by default it's security rights allow control only to SYSTEM account. You can either try to run your program as SYSTEM (ie part of OS) or go to the folder properties and change it's security rights to allow administrator to read the folder and it's contents.

If you choose to go with the security permissions and you can't find the folder to change the permissions you need to get to Folder Options (It's under Organize as Folder and Search Options), go to tab View and in the advanced settings list you'll find a checkbox named Hide protected operating system files (Recommended). Untick this checkbox and after the warning (Read it) you'll be able to see the folder in C: and D:

usually when I encounter this problem, I run Visual Studio as administrator..

This is a system folder and by default it's security rights allow control only to SYSTEM account. You can either try to run your program as SYSTEM (ie part of OS) or go to the folder properties and change it's security rights to allow administrator to read the folder and it's contents.

If you choose to go with the security permissions and you can't find the folder to change the permissions you need to get to Folder Options (It's under Organize as Folder and Search Options), go to tab View and in the advanced settings list you'll find a checkbox named Hide protected operating system files (Recommended). Untick this checkbox and after the warning (Read it) you'll be able to see the folder in C: and D:

could you please tell me what you mean by "ou can either try to run your program as SYSTEM" and i didn't quite get you concept yet because i am running VS as Admin and i don't know why access is denied

Guys, I have found out that access denied popsup at certain folder like "C:\Windows\Debug\WIA" and "D:\System Volume Information",where it is not neccesary to browse those folders so I was thinking how i can skip looking into those folders using my code, so how can i modify this code in such a way that I can skip those access denied folders?

Dim fnm As String = ""
        Dim filenames() As String = Directory.GetFiles(Cpath, "*.mp3", SearchOption.AllDirectories)
        Dim filename As String
        Dim i As Integer
        For i = 0 To filenames.Length - 1
            filename = Path.GetFileName(filenames(i))
            itm_add(filename)
            setval(1)
        Next i

And by the way thanks for the infomation adam k :)

ahm... how can you open a text file from "D:\" i have tried this:

 Dim fs As FileStream
        Dim str As StreamReader
        Dim st As String
        'ofd.ShowDialog()
        fs = New FileStream(TextBox6.Text, FileMode.OpenOrCreate, FileAccess.Read)
        str = New StreamReader(fs)
        str.BaseStream.Seek(0, SeekOrigin.Begin)
        Do While str.Peek > -1
            TextBox5.Text = str.ReadToEnd
        Loop

but it keeps on saying that access to path is denied.

This thread is more than a year old. Please read the rules which talk about resurrecting or hijacking old threads. If you want an answer then please start a new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.