471,319 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

DirectoryInfo and MoveTo() method

**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
Jan 20 '06 #1
5 4196
Is your source directory read only? Does the target directory already
exists? Either will cause a failure according to the documentation.

Dave
"AE Guy" <AE***@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
**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

Jan 20 '06 #2
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

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

Dave
"AE Guy" <AE***@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
**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


Jan 20 '06 #3
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...
Jan 23 '06 #4
Post your code.
Jan 23 '06 #5
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
Jan 23 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by MichaelH | last post: by
2 posts views Thread by Demetri | last post: by
5 posts views Thread by jman | last post: by
2 posts views Thread by Tophog | last post: by
reply views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
reply views Thread by Craig Buchanan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.