473,327 Members | 2,055 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,327 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 4313
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.