473,225 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 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 4310
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Turner | last post by:
I have created an ASP.NET page that uses the System.IO.DirectoryInfo.GetFiles() method to get a list of files in a specific directory on our web server. (I simply use this list to build some...
0
by: MichaelH | last post by:
I have written some code and it was working as expected when I was selecting my USB Drive. I was testing the code and writing the information out to the C:\ drive and the GetDirectories method was...
2
by: Demetri | last post by:
Using the GetFiles method of the DirectoryInfo instance one can pass in a search pattern of string type. For example: DirectoryInfo di = new DirectoryInfo("C:\temp"); FileInfo fi =...
5
by: jman | last post by:
I have an urgent question. I have written a .Net C# windows services that has only one key purpose: to move files from the machine that is running the service to a network download server for...
7
by: Charts | last post by:
I login as administrator of the machine. However running the following code get access denied exception for file inside the directory. The source code: DirectoryInfo target = new...
2
by: Tophog | last post by:
I haven't done a lot of file I/O in .NET and thought I had this figured out. I am simply wanting to move a UNC-based directory path to a new path using DirectoryInfo. Example: Source...
0
by: clintonG | last post by:
The Wizard is on Step5 and some TextBox validation in Step5 has to be done on the server so I've been thinking I need to use the OnActiveStepChanged event. This server-side validation has to be...
0
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi, When redirecting to my aspx page, I check if user is authenticated. If user is authenticated I use the Wizard's MoveTo method to skip the first step. This works as expected only I get a...
0
by: Craig Buchanan | last post by:
I'm using the Wizard control in the 2.0 framework. I need to perform a validation on each of the steps of the wizard in the Finish button click event. This scenario would occur if the user...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.