示例#1
0
        private void odczytToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            OpenFileDialog openFileDialog = new OpenFileDialog();

            string directory = AppDomain.CurrentDomain.BaseDirectory;

            openFileDialog.InitialDirectory = directory + "odczyt";
            openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.RestoreDirectory = true;


            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                listView1.Items.Clear();
                listView2.Items.Clear();
                listView3.Items.Clear();
                listView4.Items.Clear();
                listView5.Items.Clear();
                CalculateMacros();

                filePath = openFileDialog.FileName;

                var fileStream = openFileDialog.OpenFile();

                StreamReader reader = new StreamReader(fileStream);
                fileContent = reader.ReadToEnd();

                var ListOfWords = TextToList.method(fileContent);

                int i = 1;

                foreach (var item in ListOfWords)
                {
                    if (item == "###")
                    {
                        i++;
                    }
                    else
                    {
                        ProductAndGrams ProductAndGrams = ExtendedTextToProduct.ExtendedTextToProductFunction(item);

                        Product product = ProductAndGrams.product;

                        string ConvertedProduct = ProductToText.ConvertProductIntoText(product);

                        AddProductToEspeciallyList(ProductAndGrams.grams, ConvertedProduct, i);

                        CalculateMacros();
                    }
                }
            }
            else
            {
                MessageBox.Show("Wystąpił błąd otwierania pliku");
            }
        }
示例#2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            string tempString = ProductToText.ConvertProductIntoText(productToSend);

            //FileStream test =  File.OpenWrite("wybor.txt");

            StreamWriter streamW = new StreamWriter("wybor.txt");

            streamW.Write(tempString);

            streamW.Close();

            File.WriteAllText("IsForm2Opened.txt", "closed");

            this.Close();

            Form3 form3 = new Form3();

            form3.Show();
        }