Directory.CreateDirectory followed by Directory.Move

M

Matt MacDonald

Hi all,
I'm having a really frustrating problem. I have a web application that
needs to modify the directory structure of the underlying files. The
problem I'm having is that after the system creates a sub-directory in an
existing directory, and then I try to move the parent directory, I get an
access denied error. I've tried setting the resultant directory object to
nothing after creating it, among other things. I also tried running the
subs that do the directory io both from instanced object, as well as from
shared objects. Nothing seems to free the directory up except for time....
more time than I'm willing to accept. Is there anyway around this? Maybe
force garbage collection?

Here is the code snippet....

' Create the sub-directory
Dim d As DirectoryInfo =
IO.Directory.CreateDirectory(Current.Server.MapPath(Path))
d = Nothing

' And on a totally separate instance of the page, after creating the
sub-directory, move (rename) the parent directory
Dim d As New DirectoryInfo(Current.Server.MapPath(Path))
d.MoveTo(Current.Server.MapPath(newPath))
d = Nothing

There are no file conflicts that I can see, ie the destination directory
doesn't already exist, I'm not overwriting anything, etc. Once the
sub-directory is created, it inherits permissions from the parent, so that's
not the problem. This really shouldn't be a big deal, but it's got me
stumped. Any suggestions?

Thanks,
Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,795
Messages
2,569,644
Members
45,356
Latest member
deepthi.kodakandla

Latest Threads

Top