/// <summary> /// Упаковать директорию /// </summary> private void PackDir(ZipArchive zipArchive, RelPath relPath, PathDict excludedPathDict) { PackDir(zipArchive, GetAbsPath(relPath), GetAppFolderDir(relPath.ConfigPart, relPath.AppFolder, '/'), excludedPathDict.GetOrAdd(relPath.ConfigPart, relPath.AppFolder)); }
/// <summary> /// Очистить директорию /// </summary> private void ClearDir(RelPath relPath, PathDict excludedPathDict) { DirectoryInfo dirInfo = new DirectoryInfo(GetAbsPath(relPath)); if (dirInfo.Exists) { ClearDir(dirInfo, excludedPathDict.GetOrAdd(relPath.ConfigPart, relPath.AppFolder), out bool dirEmpty); } }
/// <summary> /// Обзор директории /// </summary> public bool Browse(RelPath relPath, out ICollection <string> directories, out ICollection <string> files) { try { string absPath = GetAbsPath(relPath); DirectoryInfo dirInfo = new DirectoryInfo(absPath); // получение поддиректорий directories = new List <string>(); DirectoryInfo[] subdirInfoArr = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly); foreach (DirectoryInfo subdirInfo in subdirInfoArr) { directories.Add(subdirInfo.Name); } // получение файлов files = new List <string>(); FileInfo[] fileInfoArr = dirInfo.GetFiles("*", SearchOption.TopDirectoryOnly); foreach (FileInfo fileInfo in fileInfoArr) { files.Add(fileInfo.Name); } return(true); } catch (Exception ex) { log.WriteException(ex, Localization.UseRussian ? "Ошибка при обзоре директории" : "Error browsing directory"); directories = null; files = null; return(false); } }
/// <summary> /// Получить абсолютный путь из относительного /// </summary> public string GetAbsPath(RelPath relPath) { return(GetAbsPath(relPath.ConfigPart, relPath.AppFolder, relPath.Path)); }