Exemplo n.º 1
0
        static LogStack compareWithFile(FileToMonitor fileToMonitor, LogStack logStack,LogStack historyStack)
        {
            if (!fileToMonitor.getPath().Equals(null))
            {
                DateTime dateToCompare = File.GetLastWriteTime(fileToMonitor.getPath());

                if (DateTime.Compare(dateToCompare, fileToMonitor.getTimeStamp()) > 0)
                {
                    StreamReader sr = new StreamReader(fileToMonitor.getPath());

                    while (!sr.EndOfStream)
                    {
                        Node node = new Node();
                        string line = sr.ReadLine();

                        if(!line.Equals(historyStack.ViewHead()))
                        {
                            node.setText(line);
                            logStack.Push(node);
                        }
                    }

                    sr.Close();
                }
            }
            return historyStack;
        }
Exemplo n.º 2
0
        private void Monitor()
        {
            StreamReader sr = new StreamReader(fileToMonitor.getPath());

            while (!sr.EndOfStream)
            {
                Node node = new Node();
                node.setText(sr.ReadLine());
                logStack.Push(node);
            }

            sr.Close();

            WriteValuesToScreen(logStack);
        }