Загрузка txt файла с сервера в listbox - C#
Формулировка задачи:
Листинг программы
- string[] data_mass = new WebClient().DownloadString(@"http://cyberforum.ru/base.txt");
- for (int i = 0; i < data_mass.Length; i++)
- {
- ListBox.Items.Add(data_mass[i]);
- }
Решение задачи: «Загрузка txt файла с сервера в listbox»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Net;
- namespace ConsoleApplication1 {
- class Program {
- static void Main(string[] args) {
- using (MemoryStream ms = new MemoryStream(new WebClient().DownloadData("your address here"))) {
- using (StreamReader sr = new StreamReader(ms)) {
- string line = null;
- while ((line = sr.ReadLine()) != null) {
- Console.WriteLine(line);
- }
- }
- }
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д