Solved

I need some help with a Directory.delete problem.

Posted on 2008-10-22
6
369 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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