Showing posts with label catch. Show all posts
Showing posts with label catch. 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...

Saturday, March 24, 2012

System.Net.Webclient screen scraping: how to gracefully handle 403 (and other) er

Understand try/catch generally. What event(s) should I be trying to catch?
Thank you,
-KF
"bruce barker" <nospam@dotnet.itags.org.nospam.com> wrote in message
news:%23F79bSINHHA.3288@dotnet.itags.org.TK2MSFTNGP03.phx.gbl...
> please read chapter on try/catch
> -- bruce (sqlwork.com)
> kenfine@dotnet.itags.org.nospam.nospam wrote:For webclient or HttpWebRequest, it normally will throw a
System.Net.WebException, however, any exception can be handled by the super
class "Exception". So you can use either
try
{
}catch(Exception)
{
}
or
try
{
}catch(WebException)
{
}
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.