Add files via upload
Error with array
This commit is contained in:
parent
14d45c3b69
commit
7f0e5e135f
8 changed files with 54 additions and 8 deletions
|
@ -38,19 +38,35 @@ namespace Tariffs
|
|||
|
||||
if (!File.Exists("list.txt"))
|
||||
{
|
||||
_ = File.Create("list.txt");
|
||||
FileStream fstr = File.Create("list.txt");
|
||||
fstr.Close();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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")
|
||||
{
|
||||
|
@ -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.
3
Tariffs/bin/Debug/list.txt
Normal file
3
Tariffs/bin/Debug/list.txt
Normal 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.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue