inimicaljords
asked on
Could not find a part of the path and access denied
I have 2 problems which I think are related and need some help with. I am writing a small program to clean some temp directories.
1) I get the following error when I run this code anywhere in my program
System.IO.Directory.GetFil es("C:\Use rs\xxx\App Data\Local \Microsoft \Windows\T emporary Internet Files\")
DirectoryNotFoundException was unhandled
Could not find a part of the path 'C:\Users\xxx\AppData\Loca l\Local\Mi crosoft\Wi ndows\Temp orary Internet Files'.
Basically I am trying to clean the temporary internet files folder. I am assuming that because it is a hidden folder the program cannot see it.
2) My program is getting the following error when attempting to delete the files
Access to the path 'C:\Users\xxx\AppData\Loca l\Temp\tes t.txt' is denied.
Wierd thing is that 98% of the files in this directory it will delete but has a problem with a few. (It is not because they are in use). The current user can manual delete this file with no problems but the program cannot. It seems as though it is a permission problem but I am not sure why. I have tried adding everyone with full control to the file and the file still cannot be deleted. I am currently running on vista.
Thanks for the help.
1) I get the following error when I run this code anywhere in my program
System.IO.Directory.GetFil
DirectoryNotFoundException
Could not find a part of the path 'C:\Users\xxx\AppData\Loca
Basically I am trying to clean the temporary internet files folder. I am assuming that because it is a hidden folder the program cannot see it.
2) My program is getting the following error when attempting to delete the files
Access to the path 'C:\Users\xxx\AppData\Loca
Wierd thing is that 98% of the files in this directory it will delete but has a problem with a few. (It is not because they are in use). The current user can manual delete this file with no problems but the program cannot. It seems as though it is a permission problem but I am not sure why. I have tried adding everyone with full control to the file and the file still cannot be deleted. I am currently running on vista.
Thanks for the help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no solution found
inimicaljords, Thanks for the points. I don't have any experience with Vista security yet, but FWIW, have you seen these links about the internet cache in Vista and IE protected mode?
Code Project - A Developer's Survival Guide to IE Protected Mode
This one is in C++, but informative to me:
http://www.codeproject.com/KB/vista-security/PMSurvivalGuide.aspx
IEBlog - Protected Mode in Vista IE7
http://blogs.msdn.com/ie/archive/2006/02/09/528963.aspx
MSDN
Understanding and Working in Protected Mode Internet Explorer
http://msdn.microsoft.com/en-us/library/bb250462.aspx
Best o' luck,
gisTimmy
Code Project - A Developer's Survival Guide to IE Protected Mode
This one is in C++, but informative to me:
http://www.codeproject.com/KB/vista-security/PMSurvivalGuide.aspx
IEBlog - Protected Mode in Vista IE7
http://blogs.msdn.com/ie/archive/2006/02/09/528963.aspx
MSDN
Understanding and Working in Protected Mode Internet Explorer
http://msdn.microsoft.com/en-us/library/bb250462.aspx
Best o' luck,
gisTimmy
Change your Programs app.manifest file to look something like the code snippet. Change your project settings to compile a user created/modified Manifest, this will request Admin Rights before running.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
ASKER
I know cleaning temp internet files for a user can be done from that user account and not the administrator. I have used many programs that can accomplish this. I just can't figure out why the program cannot see the folder but the user can.