locked
Problem with downloading files from sites. RRS feed

  • Question

  • Hi guys,

    I was trying to do "updater" for my program, but when I upload TXT document to site I just download html code (?) like this http://pastebin.com/BeWwMXp2 and I don't know how to download TXT document. There is my "updater" http://pastebin.com/ciKYpWv6.

    Sorry for my English.

    • Moved by Jamles Hez Wednesday, May 6, 2015 6:20 AM
    Monday, May 4, 2015 2:57 PM

Answers

  • Hi guys,

    I was trying to do "updater" for my program, but when I upload TXT document to site I just download html code (?) like this http://pastebin.com/BeWwMXp2 and I don't know how to download TXT document. There is my "updater" http://pastebin.com/ciKYpWv6.

    Sorry for my English.

    If you're just trying to "read" the text file from a URL, try the following:

    Private Function ReturnStringFromURL(ByVal url As String) As String Dim retVal As String Dim sb As New System.Text.StringBuilder Try Dim request As WebRequest = WebRequest.Create(url) Using response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse) Using dataStream As Stream = response.GetResponseStream Using rdr As New StreamReader(dataStream) sb.Append(rdr.ReadToEnd) End Using End Using End Using retVal = sb.ToString Catch ex As Exception retVal = Nothing End Try Return retVal End Function

    You'll need to import System.IO and System.Net


    Still lost in code, just at a little higher level.

    :-)

    • Marked as answer by Youjun Tang Thursday, May 14, 2015 3:24 AM
    Wednesday, May 6, 2015 2:26 PM

All replies

  • Hi Nkaskaj,

    You definitely ask at the incorrect forum, MSBuild forum is to discuss the Microsoft build engine aka MSBuild. Topics including: usage of MSBuild, build customization, and MSBuild extensibility via tasks, loggers and hosting.

    If you can tell us how you implement the application and by which language or technology, I can help to move the correct forum for you, and you will definitely get more sufficient suggestions from there.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 5, 2015 9:41 AM
  • Hi James,

    I am so sorry. I am using Visual Studio 2013 and Visual Basic (.NET Framework 3.5)

    Thanks for help.

    Nkaskaj

    Tuesday, May 5, 2015 10:28 AM
  • Hi Nkaskaj,

    this is less a VB implementation problem but more how you can get a working download link. If you're trying to download the txt file but instead get an html page saying "This item has moved", you need to check the reason for this. Can you use the url of the txt file in a browser instead, and does it work there? If I try the download link contained in your source code, it doesn't work but says "Invalid download link. Please request a new one." So you must first supply a valid download link to your application. Note that some links are not direct links but lead to a page that requires to confirm the download by pressing a button, and the direct link might change every time. However, I don't know how the hoster of your choice handles this. Anyway, the current link doesn't work.


    Armin

    Wednesday, May 6, 2015 2:07 PM
  • Hi guys,

    I was trying to do "updater" for my program, but when I upload TXT document to site I just download html code (?) like this http://pastebin.com/BeWwMXp2 and I don't know how to download TXT document. There is my "updater" http://pastebin.com/ciKYpWv6.

    Sorry for my English.

    If you're just trying to "read" the text file from a URL, try the following:

    Private Function ReturnStringFromURL(ByVal url As String) As String Dim retVal As String Dim sb As New System.Text.StringBuilder Try Dim request As WebRequest = WebRequest.Create(url) Using response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse) Using dataStream As Stream = response.GetResponseStream Using rdr As New StreamReader(dataStream) sb.Append(rdr.ReadToEnd) End Using End Using End Using retVal = sb.ToString Catch ex As Exception retVal = Nothing End Try Return retVal End Function

    You'll need to import System.IO and System.Net


    Still lost in code, just at a little higher level.

    :-)

    • Marked as answer by Youjun Tang Thursday, May 14, 2015 3:24 AM
    Wednesday, May 6, 2015 2:26 PM
  • Hi Nikasaj,

    What Armin wants to say :-) whatever. 

    However, the page you show is a PHP page with a download function to get a file. If you want to go around that function, you are in fact hacking. In many countries including that from Frank, Armin and mine that can result in jail penalties.

    Not so clever to help you with that ain't it?


    Success
    Cor

    Wednesday, May 6, 2015 5:05 PM