WebClient drops a wrong string

3

I'm trying to create a virtual intelligence system, and hosted the language files in my FTP. These files are from a language I made myself, called SVDB, and hosted on FTP, and when I download in the application the text file it comes with HTML. This is the original file (hosted on FTP):

default {
   wrong: "Desculpe, não entendi";
   language-name: "Português Brasileiro";
   language-code: "PT-BR";
   version: "1.0";
}
replace-strings {
   R0001: "vc|você";
   R0002: "td|tudo";
}
K00001 {
   input: "olá|ola|oi|eae";
   output: "Olá!";
   action-id: "";
}
K00002 {
   input: "tudo bem?|você está bem?";
   output: "Estou bem, obrigado por perguntar.";
   action-id: "";
}

And this is what WebClient.DownloadString() low:

ItdropsacodetotallynothingtodowithwhatIwant,andtheSVDBparseroftheerror.Thisistheaddresswherethefileishosted:

  

link

And this is the code I'm using to download the file:

Public Function GetLanguageServer(ByVal LangCode As String) As MainServer
    Dim v As New WebClient
    Dim s As String = v.DownloadString("http://server-advenker32.66ghz.com/Panthon/Server/Langs/" & LangCode.ToLower & "/input.txt")
    Return TextParser.ResolveServerFromString(s) ' o Parser tenta entender o que foi baixado aqui
End Function

So, how do I down the file from a formatting like the original shown up there?

  

Note: The permissions of the hosted file are code 744 (Public Read Permissions)

     

Note: The file is hosted on my uHostAll company FTP.

     

Note: When trying to access the file through the browser, it appears correctly and without any problem.

    
asked by anonymous 02.01.2016 / 22:43

2 answers

2

I have achieved another method, I created a WebBrowser and simply navigated to the file link, this is the method now:

Public Sub GetLanguageServer(ByVal LangCode As String)
    Dim address As String = "http://server-advenker32.66ghz.com/Panthon/Server/Langs/pt-br/input.txt"
    Dim BrowserClient As New WebBrowser
    BrowserClient.Navigate(address)
    AddHandler BrowserClient.DocumentCompleted, Sub() SDK = TextParser.ResolveServerFromString(BrowserClient.Document.Body.InnerText)
End Sub

And it worked, the Document.Body.InnerText property returned the file.

    
06.01.2016 / 01:48
-1

Alright?

Doing with WebBrowser will consume more resources than a webclient, as it is an IE wrapper and will run the entire rendering and rendering stack of internet explorer. To do what you asked for, just do it.

        //Exemplo gravando em um arquivo físico
        using (var client = new WebClient())
            client.DownloadFile("http://namitec.com.br/teste.txt", @"c:\temp\teste.txt");

        //Exemplo lendo direto para memória
        using (var client = new WebClient())
        {
            using (var stream = new MemoryStream(client.DownloadData("http://namitec.com.br/teste.txt")))
            {
                var text = Encoding.UTF8.GetString(stream.ToArray());
                Console.WriteLine(text);
            }
        }

I have taken the liberty of putting the example at this address so that you can test.

    
09.01.2016 / 03:03