locked
Unnable to connect to ftp server to upload the files RRS feed

  • Question

  • I'm trying to make an app which will make few changes to a page it downloads from a website and then again uploads it the ftp site. I am facing a problem. The code is 

    public async void parseSuspend() { string html; HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://teacherapp.comule.com/suspend.html"); try { WebResponse x =await req.GetResponseAsync(); HttpWebResponse res = (HttpWebResponse)x; if (res != null) { if (res.StatusCode == HttpStatusCode.OK) { Stream stream = res.GetResponseStream(); using (StreamReader reader = new StreamReader(stream)) { html = reader.ReadToEnd(); } HtmlDocument htmldocument = new HtmlDocument(); htmldocument.LoadHtml(html); var tabledata = htmldocument.DocumentNode.Descendants("body");// it will just give table as it is the only child HtmlNode tr = htmldocument.CreateElement("tr"); HtmlNode tdbranch = htmldocument.CreateElement("td"); tdbranch.InnerHtml = branchNew.Text; HtmlNode tdbatch = htmldocument.CreateElement("td"); tdbatch.InnerHtml = batchNew.Text; HtmlNode tdsec = htmldocument.CreateElement("td"); tdsec.InnerHtml = secNew.Text; HtmlNode tddate = htmldocument.CreateElement("td"); tddate.InnerHtml = dateNew.Text; HtmlNode tdtime = htmldocument.CreateElement("td"); tdtime.InnerHtml = timeNew.Text; HtmlNode tdsub = htmldocument.CreateElement("td"); tdsub.InnerHtml = subNew.Text; HtmlNode tdprof = htmldocument.CreateElement("td"); tdprof.InnerHtml = prof; tr.AppendChild(tdbranch); tr.AppendChild(tdbatch); tr.AppendChild(tdsec); tr.AppendChild(tddate); tr.AppendChild(tdtime); tr.AppendChild(tdsub); tr.AppendChild(tdprof); tabledata.ElementAt(0).AppendChild(tr); var htmlstring = htmldocument.ToString(); try { // Uri myuri = new Uri("ftp://ftp.teacherapp.comule.com"); //Uri relativeuri = new Uri("/public_html/suspend.html", UriKind.Relative); //Uri real = new Uri(myuri, relativeuri); WebRequest request = WebRequest.Create("ftp://ftp.teacherapp.comule.com/public_html/suspend1.html "); request.Credentials = new System.Net.NetworkCredential("a9756857", "password"); request.Proxy = null; request.Method = "STOR"; Byte[] buffer = Encoding.UTF8.GetBytes(htmlstring); Stream requeststream = await request.GetRequestStreamAsync(); await requeststream.WriteAsync(buffer, 0, buffer.Length); await requeststream.FlushAsync(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }

    }

    My laptop uses proxy "192.168.4.20" port is 3128 . Whenever I run the code I'm getting an error . "The remote name could not be resolved: 'ftp.teacherapp.comule.com'

    What should I do? Please help me. If this is done My whole project will be done. This is just a small part of the project and lot of things are dependent on this project.


    • Edited by srinath29 Thursday, October 24, 2013 5:05 AM typo
    Thursday, October 24, 2013 4:44 AM

Answers

  • Working on both!!

    Found out the reason!! Microsoft removed the capabilities to upload to ftp server when on proxy from winrt api!!!!! Took 3 days to figure!! Now finally it is working!!! Thanks to God!!  

    • Edited by srinath29 Friday, October 25, 2013 5:33 PM information added
    • Marked as answer by srinath29 Saturday, October 26, 2013 3:13 AM
    Friday, October 25, 2013 5:33 PM

All replies

  • Does it work with the IP address rather than the DNS name?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, October 24, 2013 6:05 PM
    Moderator
  • Working on both!!

    Found out the reason!! Microsoft removed the capabilities to upload to ftp server when on proxy from winrt api!!!!! Took 3 days to figure!! Now finally it is working!!! Thanks to God!!  

    • Edited by srinath29 Friday, October 25, 2013 5:33 PM information added
    • Marked as answer by srinath29 Saturday, October 26, 2013 3:13 AM
    Friday, October 25, 2013 5:33 PM