File.Move not working as expected

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I was hoping someone might be able to shed some light on this bizarre
behaviour.

I have observed some strange behaviour with System.IO.FIle.Move where it
seems to be copying a file as opposed to actually moving it. The following is
a description of my setup:

Two separate machines (A and B) both running Windows Server 2003. Machines
reside on the same domain.

An application is running on machine A and it is responsible for managing
files on machine B. In particular it will (among other things) be moving a
file from one share (share1) on machine B to another share (share2) on
machine B.

Using an example, we have a file called bla.bla that is currently sitting in
location share1. The call in the application on machine A will attempt to
move bla.bla to location share2. e.g.

File.Move(share1/bla.bla, share2/bla.bla)

This call blocks until the operation is complete however upon return rather
then seeing that bla.bla has been moved, we actually see it now exists in
both locations (share1 *AND* share2). It SHOULD only now reside in share2.

The files in question can range in size from aprox. 10MB to say 300MB

Can anyone explain this wierdness? As far as I know, it should not be
happening.

Best regards,

Danny
 
Danny said:
Using an example, we have a file called bla.bla that is currently sitting in
location share1. The call in the application on machine A will attempt to
move bla.bla to location share2. e.g.

File.Move(share1/bla.bla, share2/bla.bla)

This call blocks until the operation is complete however upon return rather
then seeing that bla.bla has been moved, we actually see it now exists in
both locations (share1 *AND* share2). It SHOULD only now reside in share2.

The files in question can range in size from aprox. 10MB to say 300MB

Can anyone explain this wierdness? As far as I know, it should not be
happening.

File.Move just passes control to the Win API's MoveFile.
See the docs of MoveFile about that "weirdness".

bye
Rob
 
Never seen this myself.

However, your design is not terribly efficient on network resources. Having
the CPU of Machine A go get the data from Machine B's first share, only to
write it to Machine B's second share, is not only wasteful of Machine A's
processing power, but every file moves across the network twice. You also
lose your security descriptors this way.

Why not set up a .Net Remoting server. Machine A sees what needs to be
done, and asks the remoting objects, running on Machine B, to move the files
from one location to another. Considerably more efficient, and you won't
run into any issues that may come from volumes that are mounted as a
"share".

--- Nick
 
Back
Top