Download .txt for memory and read

0

How to download TXT in memory, read and save a variable separated by , words? I wanted to read with the slip (I think it's the name, I do not remember ...).

Here it is, it downloads the file to RAM:

public static bool CheckUpdate()
        {
            System.Net.WebClient wb = new System.Net.WebClient(); //Classe usada para baixar o arquivo de info
            byte[] buffer = wb.DownloadData(remoteVersionFile); //Baixa o arquivo de info para a memória
            System.IO.MemoryStream mem = new System.IO.MemoryStream(buffer); //Cria um Stream para o buffer
            System.IO.StreamReader memReader = new System.IO.StreamReader(mem); //Cria um leitor para o Stream
            Version remoteVersion = new Version(memReader.ReadToEnd()); // Lê a versão do arquivo para uma variável do tipo Versio;
            memReader.Close();
            mem.Close();

            Version localVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // Retorna a versão do Assembly (Programa) em execução
            return remoteVersion > localVersion; //Retorna true se a versão na internet for maior que a versão do aplicativo em execução;
        }'

Here is my variable, which I keep in txt and read in txt when it is in RAM:

"NoiseFix.cs",
"HPArmorDigital.cs",
"Nomes das ruas.cs",
"Neon.cs",
"Indicador cansaço.cs",
"Sensitivity.cs",
"Strobs.cs",
"Memoryfix.cs",
"MFGTAVH.cs",
"Fogo no escapamento.cs",
"PontosCardeais.cs",
"Xenon.cs",
"MarcasDeTiro.cs",
"Zoom.cs",
"PerPixelLighting.cs",
"Sun.cs",
"Sunlight.cs",
"RainModEffect.cs",
"SnowFlakes.cs",
"Recarregararma.cs",
"Exhaust.cs",
"Skybox.cs",
"Fontfixed.cs",
"camshake.cs",
"turn_indicators.cs",
"particles.cs",
"Skyboxv2.cs",
    
asked by anonymous 17.08.2018 / 18:30

1 answer

0

If I understand correctly you want to know how to write and read a txt, being at the time of reading separate by ",". I'll leave an example here, see if it suits you.

Type Txt:

IList<string> lista = new List<string>() { "teste", "teste2", "teste3"};

File.WriteAllLines("caminho_arquivo.txt", lista);

Where, the file path is the file that will be created, and the list is a collection of strings (List or Array), where each element of it will be a line of the txt.

Read Txt:

string[] lista = File.ReadAllLines("caminho_arquivo.txt");

foreach(string linha in lista)
{
     //Codigo para cada item da lista de linhas do arquivo
}

Where File.ReadAlllines returns an Array of strings, being formed by each line of the file.

Split () example

string nomes = "Joao, Paulo, Sergio, Rodrigo, Pedro";

string[] lista = nomes.Split(',');

Where, split breaks its string on the character you entered, returning an array of string.

    
17.08.2018 / 19:12