DirectoryInfo and MoveTo() method

G

Guest

**I just realized I initially posted this in the wrong group, sorry to those
of you who see it twice

I have a windows service written in C# that WAS moving files individually.
Now I am trying to make it move entire directories. When trying to use the
DirectoryInfo.MoveTo() method I am getting a "access to the path is denied"
exception. This is being developed on the local system, service is starting
up with the local system account, and it work fine when using
FileInfo.MoveTo().

Any advice would be appreciated
 
D

D. Yates

Is your source directory read only? Does the target directory already
exists? Either will cause a failure according to the documentation.

Dave
 
G

Guest

Thanks for replying!

I don't read where the source directory cannot be read only. To answer you
question, yes it is, but I've tried changing the read only attribute
(manually) and it didn't make a difference.

The directory doesn't already exist where I am trying to move it to. But on
that topic, I'm using the .FullName of the target DirectoryInfo, and adding
"//" + source.Name, so it ends up being "C:/TEMP2/BLUE".

Any other suggestions would be appreciated. I guess I can always copy then
delete, but I was wanting to just do a Move.

Thanks
 
G

Guest

I am pulling my hair out since I know this must be quite simple. Does anybody
else have any suggestions? I tried it with a new set of folders, none of
which were read only. The code is quite simple. I FOREACH through a
collection of DirectoryInfo objects, test each one for the existance of a
particular file, then try to use the MoveTo() method.

Thanks in advance...
 
M

Marc Gravell

Any chance of a simplified (but complete) code snippet that illustrates the
problem? Preferably one that sets up some dummy data on the file system
first (or includes info on how to create a file structure that breaks)...

Marc
 

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

Top