unhandled exception : System.net.webException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anandthite7
    New Member
    • Feb 2012
    • 7

    unhandled exception : System.net.webException

    Hi,
    I am using a C# console appliaction to FTP a file from Windows to Unix. Here i am using the following code :

    Code:
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(myUri);
    request.Method = WebRequestMethods.Ftp.UploadFile;
    * myUri is the URI for my Unix machine

    I am getting an error of
    System.Net.WebE xception : The remote name could not be resolved : 'myUri'

    Kindly suggest some pointers in resolving the error.
    Thanks in advance!
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    It would help if you posted the declaration code for myUri since the exception is indicating that this code is incorrect.

    -Frinny

    Comment

    • anandthite7
      New Member
      • Feb 2012
      • 7

      #3
      The code for myUri is :

      Code:
      Uri newUri = new Uri("ftp://www.xyz.com");
      i can write the URI directly in the ".Create()" method as well, i have just taken it as "newUri" for convenience

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        The error is stating that the web request couldn't be made because it could not resolve the URL that you've provided.

        Are you sure that "ftp://www.xyz.com" exists?
        It can't be resolved.

        -Frinny

        Comment

        • anandthite7
          New Member
          • Feb 2012
          • 7

          #5
          Thanks Frinny!..
          Yes the ftp link does exist..i will try with the ip address for ftp and check for the working..

          Comment

          Working...