Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have being pulling my hair out and spending way to much time on google. I am writing my own backup programme and would like to have access over my machine. While trying to read all the file names in My Documents. I get the error code that I can not access My Music. Which is of course a pain in the back side. How do I get around this.

VB
{Program is set to require admin rights at execution}


dim Folder as string 
folder=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
dim sPattern as string
sPatter="*.*"
for each File_Entry as string in Direcotry.GetFiles(Folder,sPattern,IO.SearchOption.AllDirectories)
'Code here to do stuff with files.
next


I get this error
<br />
Access to the path 'C:\Users\{current user}\Documents\My Music\' is denied.<br />


I have tried the following.

On Error Resume Next. this of course stops it in its tracks

Try Catch End Try. again stops in its tracks

Setting Access Rules. Unless I am doing it wrong, Does not work

Continue For in Try Again bad idea

Any Help would be fantastic. I don't want to copy or minipulate the files. I just want to get a complet list of filename and directory structures out of it.

Cheers
Posted
Updated 6-Sep-11 21:06pm
v4

You will not be able to access the Documents folder of another user unless you yourself are running with administrator privileges.
So AFAIK, I don't think there is any workaround to your problem.
 
Share this answer
 
Comments
Dool_Cookies 6-Aug-11 6:18am    
I am the only use on this system with "admin" rights. For both user and application.
Sergey Alexandrovich Kryukov 6-Aug-11 23:19pm    
Please see my comment below.
--SA
Sergey Alexandrovich Kryukov 6-Aug-11 23:19pm    
Agree, my 5. But having admin privileges in not enough. One also needs to run code under elevated privileges, "Run as administrator". In Win7, this is not the same as just participation in Administrator group.
--SA
May be this will help you to save hairs: FileScan Application.
 
Share this answer
 
Comments
Dool_Cookies 6-Aug-11 6:19am    
Thank you, I will give the code a go and let you know.
Dool_Cookies 6-Aug-11 6:46am    
Just download the code sample project. Thank you very much. A bit of reworking and I am sure it will do what I want it to do =) I might even re-work so I can added to my DLL that I made with all the little tid bits of stuff =)
Dool_Cookies 7-Sep-11 3:07am    
Tried and I guess I am missing something =(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900