コード例 #1
0
        /// <summary>
        /// Count number of lines in a text file
        /// </summary>
        public static NumberOfLinesResult GetNumberOfLines(string fileName)
        {
            NumberOfLinesResult Result = null;
            bool         BooleanResult;
            StreamReader InputFileStream;

            BooleanResult = File.Exists(fileName);
            if (BooleanResult)
            {
                InputFileStream = new System.IO.StreamReader(fileName);
                Result          = FileUtility.GetNumberOfLines(InputFileStream);
                InputFileStream.Close();
            }
            return(Result);
        }
コード例 #2
0
        public static NumberOfLinesResult GetNumberOfLines(TextReader inputStream)
        {
            NumberOfLinesResult Result = new NumberOfLinesResult();
            string CurrentLine;

            // Check not null object
            if (inputStream != null)
            {
                // Count number of lines
                while ((CurrentLine = inputStream.ReadLine()) != null)
                {
                    if (CurrentLine.Length == 0)
                    {
                        Result.NumberOfEmptyLines++;
                    }
                    Result.NumberOfLines++;
                }
                // DO NOT CLOSE, IT'S PARENT FUNCTION JOB
                // inputStream.Close ();
            }

            return(Result);
        }
コード例 #3
0
ファイル: FileUtility.cs プロジェクト: tdhieu/openvss
		public static NumberOfLinesResult GetNumberOfLines (TextReader inputStream)
		{
			NumberOfLinesResult	Result = new NumberOfLinesResult ();
			string				CurrentLine;

			// Check not null object
			if (inputStream != null)
			{
				// Count number of lines
				while ((CurrentLine = inputStream.ReadLine ()) != null)
				{
					if (CurrentLine.Length == 0)
						Result.NumberOfEmptyLines++;
					Result.NumberOfLines++;
				}
				// DO NOT CLOSE, IT'S PARENT FUNCTION JOB
				// inputStream.Close ();
			}

			return Result;
		}