コード例 #1
0
        /// <summary>
        /// Compiles a list of files and directories to archive
        /// </summary>
        /// <returns>
        /// returns a multi line status
        /// </returns>
        public string Status()
        {
            var retVal = string.Empty;

            if (DirectoriesToArchive.Count > 0)
            {
                retVal = "Directories to archive\n";

                retVal = DirectoriesToArchive.Aggregate(
                    retVal,
                    (current, directory) => current + $"\t{directory}\n");
            }

            if (FilesToArchive.Count > 0)
            {
                retVal += "Files to archive\n";
                retVal  = FilesToArchive.Aggregate(
                    retVal,
                    (current, file) => current + $"\t{file}\n");
            }

            if (string.IsNullOrEmpty(retVal))
            {
                retVal = "Nothing to Archive";
            }

            return(retVal);
        }
コード例 #2
0
        /// <summary>
        /// Add a single file to be archived
        /// </summary>
        /// <param name="filename">
        /// Name of file
        /// </param>
        /// <param name="archiveComment">
        /// Any comments to be attahced to the status - why do we archive this file
        /// </param>
        /// <returns>
        /// Indication of success
        /// </returns>
        public bool AddFile(string filename, string archiveComment = null)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }

            FilesToArchive.Add(filename);
            return(true);
        }