Solved

I need some help with a Directory.delete problem.

Posted on 2008-10-22
6
363 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
  • 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now