Solved

I need some help with a Directory.delete problem.

Posted on 2008-10-22
6
372 Views
Last Modified: 2013-12-17
I have created a C# Console application that automatically goes into a folder and cleans up some subfolders. When running the script it works fine for the most part. but on certain folders. i get the following error:

Access to path '<drive>:\users\<users folder>\<subfolder>' is denied.

I have checked my permisions on the files/folders and on all of them i have full permissions for all files, folders, and subfolders. so why am i getting this message? any help would be appreciated.


System.IO.Directory.Delete(path_to_delete, true);

Open in new window

0
Comment
Question by:tosmserversupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
RishadanPort earned 500 total points
ID: 22781831
This could happen if a file is currently in use by another program, or the current application.
0
 

Author Comment

by:tosmserversupport
ID: 22781844
I will look into this and see if that is the problem. thank you for your prompt response.
0
 
LVL 3

Expert Comment

by:trunghieubkit
ID: 22783435
You may be opening the folder by the Explorer

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Closing Comment

by:tosmserversupport
ID: 31508994
thank you for your help. it appears that there is a process running on the server which is preventing it from being deleted.
0
 

Author Comment

by:tosmserversupport
ID: 22787048
Thanks everyone for their prompt reply. it seems a program is accessing the files while i am attempting to delete them. I will write some code to remove these locks before deleteing the folders.
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22788761
Did I answer your question fully? I am just wondering why you gave the grade of "B". Usually you give the grade B when your answer was not answered fully
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net figure out error 3 44
parsing question on dynamic concatenation 3 39
Run tasks synchronously in background thread 19 80
EF5 How do I stop pre-compiled views? 8 48
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question