示例#1
0
        /// <summary>
        /// Returns a list of lines in a file.
        ///
        /// If trim is true then all lines are trimmed and any lines
        /// that then have length 0 are discarded.
        ///
        /// If trim is false then all lines are added unchanged.
        ///
        /// The file path is an absolute path.
        ///
        /// This method is a generalization of a method originally
        /// in the Teaching Preferences web application.
        ///
        /// If an exception occurs, a list with 0 items will be
        /// returned.
        ///
        /// In August 2009, refactored to use StringTools.LineList.
        /// </summary>
        /// <param name="filepath">The absolute file path</param>
        /// <returns>The list of the non-empty lines</returns>
        public static List <string> FileDataAbsolutePath(string filepath, bool trim)
        {
            string content = GetFileAsText(filepath);

            return(StringTools.LineList(content, trim));
        }