Exemplo n.º 1
0
 /// <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));
 }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Получить абсолютный путь из относительного
 /// </summary>
 public string GetAbsPath(RelPath relPath)
 {
     return(GetAbsPath(relPath.ConfigPart, relPath.AppFolder, relPath.Path));
 }