Example #1
0
        private bool readFile(string file)
        {
            if (file == String.Empty)
            {
                Console.WriteLine("-> No file given! Press any key.");
                Console.ReadKey();
                return(true);
            }

            FileInfo fi = new FileInfo(file);

            if (!fi.Exists || fi.Length <= 0)
            {
                Console.WriteLine("-> File not found or to small! Press any key.");
                Console.ReadKey();
                return(true);
            }

            for (int i = 0; i < VALID_INPUTS.Length; i++)
            {
                if (fi.Extension.ToUpper() == VALID_INPUTS[i])
                {
                    m_iExtensionIndex = (eValidExtensions)i;
                    file = fi.FullName;
                    StreamReader tr = new StreamReader(file);

                    m_FileData = new List <string>();

                    string line = "";
                    while ((line = tr.ReadLine()) != null)
                    {
                        line = line.Trim();

                        m_FileData.Add(line);
                    }

                    tr.Close();
                }
            }

            if (m_FileData.Count <= 0)
            {
                Console.WriteLine("-> No CKT-PLC code lines found! Press any key.");
                Console.ReadKey();
                return(true);
            }

            m_bFileLoaded = true;
            return(false);
        }
Example #2
0
		private bool readFile(string file)
		{
			if(file == String.Empty)
			{
				Console.WriteLine("-> No file given! Press any key.");
				Console.ReadKey();
				return true;
			}

			FileInfo fi = new FileInfo(file);
			if(!fi.Exists || fi.Length <= 0)
			{
				Console.WriteLine("-> File not found or to small! Press any key.");
				Console.ReadKey();
				return true;
			}

			for (int i = 0; i < VALID_INPUTS.Length; i++)
			{
				if (fi.Extension.ToUpper() == VALID_INPUTS[i])
				{
					m_iExtensionIndex = (eValidExtensions)i;
					file = fi.FullName;
					StreamReader tr = new StreamReader(file);

					m_FileData = new List<string>();

					string line = "";
					while((line = tr.ReadLine()) != null)
					{
						line = line.Trim();
						
						m_FileData.Add(line);
					}

					tr.Close();
				}
			}

			if(m_FileData.Count <= 0)
			{
				Console.WriteLine("-> No CKT-PLC code lines found! Press any key.");
				Console.ReadKey();
				return true;
			}

			m_bFileLoaded = true;
			return false;
		}