Beispiel #1
0
        static void Main(string[] args)
        {
            bool operationBeggin = true;

            while (operationBeggin)
            {
                WorkWithFile firstSeance = new WorkWithFile();
                //firstSeance.ExecuteOperationCreate();
                //firstSeance.ExecuteOperationChange();
                firstSeance.ExecuteOperationOpen();
                //firstSeance.ExecuteOperationSave();


                Console.WriteLine("Do you wan to continue work with files (true/false)");
                try
                {
                    operationBeggin = Convert.ToBoolean(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Error with the answer");
                    break;
                }
            }
        }
Beispiel #2
0
        public override void Change(string fullName)
        {
            //не работает как хочу(
            bool          continueAdd = true;
            var           writerXML   = xml.CreateWriter();
            XmlTextWriter XmlWriter   = new XmlTextWriter(fullName, null);

            XmlWriter.WriteStartDocument();


            while (continueAdd)
            {
                Console.WriteLine("Put start element");
                //XmlWriter.WriteStartElement(Console.ReadLine());
                XmlWriter.WriteStartElement("Settings");

                Console.WriteLine("Put start element");
                //XmlWriter.WriteStartElement(Console.ReadLine());
                XmlWriter.WriteStartElement("TimeTrans");

                Console.WriteLine("Put start attribute");
                //XmlWriter.WriteStartAttribute(Console.ReadLine());
                XmlWriter.WriteStartAttribute("TransD", null);

                Console.WriteLine("Put write string");
                //XmlWriter.WriteString(Console.ReadLine());
                XmlWriter.WriteString("TransDSE");

                XmlWriter.WriteEndAttribute();

                Console.WriteLine("Put start attribute");
                //XmlWriter.WriteStartAttribute(Console.ReadLine());
                XmlWriter.WriteStartAttribute("TransH", null);

                Console.WriteLine("Put write string");
                //XmlWriter.WriteString(Console.ReadLine());
                XmlWriter.WriteString("TransHSE");

                XmlWriter.WriteEndAttribute();

                Console.WriteLine("Put start attribute");
                //XmlWriter.WriteStartAttribute(Console.ReadLine());
                XmlWriter.WriteStartAttribute("TransM", null);

                Console.WriteLine("Put write string");
                //XmlWriter.WriteString(Console.ReadLine());
                XmlWriter.WriteString("TransMSE");
                XmlWriter.WriteEndAttribute();
                XmlWriter.WriteEndElement();
                XmlWriter.WriteEndElement();

                continueAdd = WorkWithFile.ContinueAddText();
            }
            Console.WriteLine("------Changing was done------");
            XmlWriter.Close();
        }
Beispiel #3
0
        public override void Change(string fullName)
        {
            using (StreamWriter txt = new StreamWriter(fullName, true, System.Text.Encoding.Default))
            {
                bool continueAddText = true;
                while (continueAddText)
                {
                    Console.WriteLine("Put one line to add into document");
                    txt.WriteLine(Console.ReadLine());
                    continueAddText = WorkWithFile.ContinueAddText();
                }

                Console.WriteLine("------Changing was done------");
                txt.Close();
            }
        }