PC Review


Reply
Thread Tools Rate Thread

Access Denied on folder after using DirectoryInfo.Delete(true)

 
 
Zeb
Guest
Posts: n/a
 
      4th Jan 2007
Hi

I'm using DirectoryInfo.Delete so that when a product is removed, all
it's associated images (including the folder they sit in) are deleted.

This actually seems to work fine. However, the folder is not deleted,
but stays and becomes totally locked down. I can no longer open it in
Windows Explorer and when I try to re-launch VS 2005 debug, it
complains because it can no longer monitor that folder .. because it's
denied access.

Any ideas what could be causing this? When the site goes live I don't
want to end up with a load of locked and redundant folders.

I'm guessing it's something to do with the folder being in use by the
..net framework, although I've no idea why it doesn't get deleted. I was
wondering if there's some kind of final cleanup (like a .dispose) I
need to do with the DirectoryInfo object to free up the folder for
deletion?

Any ideas welcome!


Thanks,

Matt

 
Reply With Quote
 
 
 
 
Zeb
Guest
Posts: n/a
 
      5th Jan 2007
Just another quick though after sleeping on it!

Could this be because I had previously opened the folder to check that
it exists and contains files? I was doing this to make sure that there
is a folder to begin with and that it's then deleted. When I run the
delete in the web app, I have the parent folder open (ie. the folder
that contains the folder to be deleted).

Could this be causing it to become locked?

 
Reply With Quote
 
Zeb
Guest
Posts: n/a
 
      8th Jan 2007
Any ideas at all?

I've used the same code for associated images with News items as well
as Products and I'm getting exactly the same thing. If I delete a news
item, the images folder for that news item becomes stuck and locked,
which then causes problems with the news page itself.

The one thing I've not tried yet, which I might try in a moment, is to
properly publish the site rather than running in debug and see if that
makes a difference.

 
Reply With Quote
 
Zeb
Guest
Posts: n/a
 
      19th Jan 2007
Well I give up!

In the end I've decided to simply delete the files within the folder,
but leave the folder alone. This is fine as it's the files that take up
all the space.

If anyone does want to have a stab at solving this puzzle, I'd be
interested to hear any ideas.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DirectoryInfo.delete(true) access denied MP Microsoft C# .NET 0 12th Jan 2007 02:21 PM
Access is Denied attempting to delete folder... Jeff N. Windows XP General 3 26th Dec 2005 09:25 AM
Get access denied error when using DirectoryInfo.delete =?Utf-8?B?Q2hhcnRz?= Microsoft C# .NET 7 17th Nov 2005 01:50 AM
access denied when trying to delete folder =?Utf-8?B?VC5PLk0u?= Windows XP Help 1 28th Nov 2004 12:49 PM
cannot delete folder, access denied beppe005 Windows XP Help 2 25th Mar 2004 07:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:28 PM.