예제 #1
0
        /// <summary>
        /// 复制指定的文件
        /// </summary>
        /// <param name="srcFolder">源文件夹</param>
        /// <param name="destFolder">目的文件夹</param>
        /// <param name="searchPattern">搜索表达示</param>
        /// <param name="overwrite">是否覆盖</param>
        public static void CopyFiles(string srcFolder, string destFolder, string searchPattern, bool overwrite = false)
        {
            var files = QbFolder.SearchFiles(srcFolder, searchPattern);

            if (files == null || files.Length == 0)
            {
                return;
            }
            foreach (var file in files)
            {
                file.CopyTo(Path.Combine(destFolder, file.Name), overwrite);
            }
        }
예제 #2
0
        /// <summary>
        /// 删除指定的文件
        /// </summary>
        /// <param name="folder">文件夹</param>
        /// <param name="searchPattern">搜索表达示</param>
        /// <param name="searchOption">搜索选项</param>
        public static void DeleteFiles(string folder, string searchPattern, SearchOption searchOption = SearchOption.TopDirectoryOnly)
        {
            var files = QbFolder.SearchFiles(folder, searchPattern, searchOption);

            if (files == null || files.Length == 0)
            {
                return;
            }
            foreach (var file in files)
            {
                file.Delete();
            }
        }