File Copy problem

B

bob

Hi,
Its bizarre.
Development platform Win2003 server VS2008.

Archiving a file by moving it from one directory to another.
On development machine all is fine.
File MRSLWCCWDAL0000.G14 (real file name) moves from live directory
to archive directory which is a subdirectory of the live directory
which is on a LAN server.

On target client machine (XPProfessional).
The file moves but every character left of the extension separator
gets stripped off. So in the archive directory you end up with a file
called '.G14'
I have used the directory and file static methods that move, I have
tried copy and delete I have put a thread sleep between copy and
delete.
Result is always the same.
Works on development platform, strips the file name on the client
machine.

Any clues where to look would be appreciated.
thanks
Bob
 
P

Peter Duniho

[...]
The file moves but every character left of the extension separator
gets stripped off. So in the archive directory you end up with a file
called '.G14'
I have used the directory and file static methods that move, I have
tried copy and delete I have put a thread sleep between copy and
delete.
Result is always the same.
Works on development platform, strips the file name on the client
machine.

Any clues where to look would be appreciated.

Definitely not a C# problem. Probably not a .NET problem. What file
system is the client using? Even FAT I would expect to work correctly,
but I suppose there might be some file system issue I've forgotten about.

For sure, you need to start by figuring out what the system configuration
difference is that's causing the issue, whether that's a file system
difference, .NET version difference, or strictly an OS version
difference. You might also try writing some unmanaged code to do the same
thing, to see if it's something inherent in the unmanaged API or something
getting fouled up in .NET.

This, of course, all assumes that there's nothing wrong with your own
code. Without a concise-but-complete code example that reliably
demonstrates the problem, there's no way for any of us to know that for
sure.

Pete
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi,
Its bizarre.
Development platform Win2003 server VS2008.

Archiving a file by moving it from one directory to another.
On development machine all is fine.
File MRSLWCCWDAL0000.G14 (real file name) moves from  live directory
to archive directory which is a subdirectory of the live directory
which is on  a LAN  server.

On target client machine (XPProfessional).
The file moves but every character left of the extension separator
gets stripped off. So in the archive directory you end up with a file
called  '.G14'
I have used the directory and file static methods that move, I have
tried copy and delete I have put a thread sleep between copy and
delete.
Result is always the same.
Works on development platform, strips the file name on the client
machine.

Any clues where to look would be appreciated.
thanks
Bob

Hi,

That's weird
Do you get any error?
Can you post your actual code?
 
B

bob

Hi Pete and Ignacio,
Thank you for your responses.
Common to all attempts has been the literal string sArchivePath.

Because the source file is always coming from the same location
string sFile = sFileName.Substring(32); will produce the file name.

My last attempt:
private static void ArchiveDAL(string sFileName)
{
string sFile = sFileName.Substring(32);
string sArchivePath = @"\\meteror\e
drive\exportdata\11\archive\" + sFile;
File.Copy(sFileName, sArchivePath);
System.Threading.Thread.Sleep(1000);//Weirdo File problem
on Julia's laptop. only leaves the file named with the extension.
File.Delete(sFileName);

}
regards
Bob
 
P

Peter Duniho

Hi Pete and Ignacio,
Thank you for your responses.
Common to all attempts has been the literal string sArchivePath.

Because the source file is always coming from the same location
string sFile = sFileName.Substring(32); will produce the file name.

My last attempt: [incomplete code example snipped]

Here are some links you may find helpful:
http://www.yoda.arachsys.com/csharp/complete.html
http://www.yoda.arachsys.com/csharp/incomplete.html
http://sscce.org/ (some Java-centric stuff, but mostly applicable to any
programming questions)

That said, you have a serious maintenance problem, if not the actual
source of your bug.

You should be using the Path.GetFileName() method to parse out the actual
filename, rather than depending on some specific character count. You
_say_ that the path is always the same, but there's absolutely nothing in
your code example that assures us that that's really true, and it's the
most obvious explanation for why the resulting filename is wrong.

Try this:

private static void ArchiveDAL(string sFileName)
{
string sFile = Path.GetFileName(sFileName);
string sArchivePath = @"\\meteror\edrive\exportdata\11\archive\" +
sFile;

File.Move(sFileName, sArchivePath);
}

If that doesn't fix your problem, then post a true concise-but-complete
code example that reliably demonstrates the problem. Without that,
there's very little chance of figuring the problem out.

Pete
 

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