Wednesday, March 28, 2012

System.IO.File.Copy not copying and no error

I'd suggest wrapping the copy in a Try/Catch block just to be sure. Then
throw a new exception, outputing your source/destination paths along with
the original exception:

Try
System.IO.File.Copy(Source,Dest)
Catch ex as exception
throw new Exception("Source: '" & source & "' - Dest: '" & dest &
"'",ex)
end try

also, put a break point at the Throw, and examine your variables.

"Xander Q." <xander_q@dotnet.itags.org.hotmail.com> wrote in message
news:1958ff15.0307052341.260d3083@dotnet.itags.org.posting.google.c om...
> Something really strange is happening. i'm using the following code to
> copy a file. this worked on my development machine, but when i moved
> it to the server (win2k) it is not copying the file and not generating
> an error. it just merrily goes on.
> ---------------------
> source= Server.MapPath("/TTClaimsForm2/Reports/xxx.doc")
> dest= Server.MapPath("/TTClaimsForm2/Reports/Temp/xxx.doc")
> System.IO.File.Copy(source, dest)
> ---------------------
>
> i checked the value of dest and it's correct. i replaced it with an
> empty string and it gave an error as expected.
> BUT i noticed that if i hard code destination like this:
> System.IO.File.Copy(source,
> "C:\inetpub\wwwroot\ttclaimsform2\Temp\xxx.doc") then the copy works.
> how can this be happening?"David Waz..." <dlw@.pickpro.com> wrote in message news:<bhZNa.1682$Ro2.1449@.newssvr31.news.prodigy.com>...
> I'd suggest wrapping the copy in a Try/Catch block just to be sure. Then
> throw a new exception, outputing your source/destination paths along with
> the original exception:

ah yes i neglected to mention that i already did that, and the value
of 'dest' is correct. it is the same as the hard-coded string and yet
it fails...

damn i hate this stuff!!!

but thx for the input...

0 comments:

Post a Comment