Add files via upload

Error with array
This commit is contained in:
Андрей 2020-01-20 15:38:50 +03:00 committed by GitHub
parent 14d45c3b69
commit 7f0e5e135f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 8 deletions

View file

@ -38,19 +38,35 @@ namespace Tariffs
if (!File.Exists("list.txt"))
{
_ = File.Create("list.txt");
FileStream fstr = File.Create("list.txt");
fstr.Close();
}
try
{
client.DownloadFile(remoteFile, "list.txt");
if (File.Exists("list.txt"))
{
String boxres = MessageBox.Show("Обновить кэшированный файл с тарифами?",
"Вопрос",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information).ToString();
if (boxres == "Yes")
{
client.DownloadFile(remoteFile, "list.txt");
}
}
else
{
client.DownloadFile(remoteFile, "list.txt");
}
}
catch (WebException)
{
String clickedButton = MessageBox.Show("Не удалось получить сведения о тарифах с сервера.\n" +
"Поиск кэшированного файла...",
"Ошибка", MessageBoxButtons.AbortRetryIgnore,
MessageBoxIcon.Error).ToString();
MessageBoxIcon.Warning).ToString();
if (clickedButton == "Abort")
{
@ -80,11 +96,11 @@ namespace Tariffs
if (!(firstcode == "Tariffs"))
{
_ = MessageBox.Show("Неверный тип файла!\n\n" +
"Так как невозможно загрузить тарифы,\n" +
"Приложение будет закрыто.",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
"Так как невозможно загрузить тарифы,\n" +
"Приложение будет закрыто.",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
s.Close();
Close();
}
@ -103,6 +119,33 @@ namespace Tariffs
}
StreamReader listfile = new StreamReader("list.txt");
String firststr = listfile.ReadLine();
String[][] tariffsArr = new String[50, 7];
String line = "";
int i = 0;
if (!(firststr == "Tariffs"))
{
MessageBox.Show("Неверный тип файла!\n\n" +
"Так как невозможно загрузить тарифы,\n" +
"приложение будет закрыто.",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
listfile.Close();
Close();
}
while ((line = listfile.ReadLine()) != null)
{
if (!line.StartsWith("#"))
{
tariffsArr[i] = line.Split(new char[] {','});
}
i++;
}
listfile.Close();
}
}

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,3 @@
Tariffs
#Operator,Tariff, MINS,SMS,MMS, GB,pay
MegaFon,Включайся!Открывай,250,200,9.9руб,2,280

Binary file not shown.

Binary file not shown.