Showing posts with label paths. Show all posts
Showing posts with label paths. Show all posts

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...

System.IO.File class and IP paths?

I try to use System.IO.File.Copy where the source is
"\\10.100.100.1\myfolder\test.txt"

When running the aspx file on the server (the server is
also the client) it works, but when using another NT
client it does not work.
The err.description says "Could not find file ..."
System.IO.File.Exists return false here.

But If I manually paste in \\10.100.100.1
\myfolder\test.txt in the IE address field and press "Go"
the file is found.

Strange or not?Hi,

I don't think that the default asp.net user got rights to access network
resources.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!