Delete() 공개 정적인 메소드

public static Delete ( string path ) : void
path string
리턴 void
예제 #1
0
        public void DeleteIndex(string indexName)
        {
            lock (this)
            {
                if (_writers.TryGetValue(indexName, out var writer))
                {
                    writer.IsClosing = true;
                    writer.Dispose();
                }

                if (_indexPools.TryRemove(indexName, out var reader))
                {
                    reader.Dispose();
                }

                _timestamps.TryRemove(indexName, out var timestamp);

                var indexFolder = PathExtensions.Combine(_rootPath, indexName);

                if (Directory.Exists(indexFolder))
                {
                    try
                    {
                        Directory.Delete(indexFolder, true);
                    }
                    catch { }
                }

                _writers.TryRemove(indexName, out writer);
            }
        }
예제 #2
0
 private bool IsIndexCorrupted(Lucene.Net.Store.Directory directory)
 {
     if (directory is FSDirectory && IndexReader.IndexExists(directory))
     {
         bool unexpectedProcessTermination = IndexReader.IsLocked(directory);
         if (unexpectedProcessTermination)
         {
             try
             {
                 _log.Error("Try to cleanup index after unexpected Process Termination...");
                 Directory.Delete(_settings.IndexPath, true);
                 Directory.CreateDirectory(_settings.IndexPath);
                 return(true);
             }
             catch (Exception accessEx)
             {
                 _log.Error("Could not cleanup index after unexpected Process Termination. Try simply unlock now.", accessEx);
                 try
                 {
                     IndexReader.Unlock(directory);
                 }
                 catch (Exception ex)
                 {
                     _log.Error("Could not unlock index after unexpected Process Termination. Giving up now.", ex);
                 }
             }
         }
     }
     return(false);
 }
예제 #3
0
        /// <summary>
        /// Removes the directory and intermediates files.
        /// </summary>
        public static void DeleteTemporaryOutputFiles()
        {
            Logger.Instance.Debug("");
            Logger.Instance.Debug(" Assembly: iTin.Core.IO, Namespace: iTin.Core.IO, Class: File");
            Logger.Instance.Debug(" Removes the directory and intermediates files");
            Logger.Instance.Debug(" > Signature: (void) DeleteTemporaryOutputFiles()");

            string tempDirectory = TempDirectoryFullName;

            bool existTempDirectory = NativeDirectory.Exists(tempDirectory);

            if (!existTempDirectory)
            {
                Logger.Instance.Debug("  > Output: Nothing to do, temp directory not exist");
                return;
            }

            try
            {
                Array.ForEach(NativeDirectory.GetFiles(tempDirectory), NativeFile.Delete);
                NativeDirectory.Delete(tempDirectory);
                Logger.Instance.Debug("  > Output: Temp directory has been deleted correctly");
            }
            catch (NativeIO.IOException)
            {
            }
        }
예제 #4
0
        /// <summary>
        ///     Update to the current version.
        /// </summary>
        /// <param name="detectDataChanges">Boolean indicating whether the update should also look for changes in data.</param>
        /// <param name="progress">Optional object to which update progress is reported.</param>
        /// <returns>Returns the <see cref="UpdateReport" /> containing all changes.</returns>
        /// <exception cref="InvalidOperationException">Definition is up-to-date.</exception>
        public UpdateReport Update(bool detectDataChanges, IProgress <UpdateProgress> progress = null)
        {
            if (DefinitionVersion == GameVersion)
            {
                throw new InvalidOperationException();
            }

            var previousVersion = DefinitionVersion;

            var exdPackId          = new PackIdentifier("exd", PackIdentifier.DefaultExpansion, 0);
            var exdPack            = Packs.GetPack(exdPackId);
            var exdOldKeepInMemory = exdPack.KeepInMemory;

            exdPack.KeepInMemory = true;

            string       tempPath = null;
            UpdateReport report;

            try {
                using (var zip = new ZipFile(StateFile.FullName, ZipEncoding)) {
                    tempPath = ExtractPacks(zip, previousVersion);
                    var previousPack = new PackCollection(Path.Combine(tempPath, previousVersion));
                    previousPack.GetPack(exdPackId).KeepInMemory = true;
                    var previousDefinition = ReadDefinition(zip);

                    var updater = new RelationUpdater(previousPack, previousDefinition, Packs, GameVersion, progress);

                    var changes = updater.Update(detectDataChanges);
                    report = new UpdateReport(previousVersion, GameVersion, changes);

                    var definition = updater.Updated;

                    StorePacks(zip);
                    StoreDefinition(zip, definition, DefinitionFile);
                    StoreDefinition(zip, definition, string.Format("{0}/{1}", definition.Version, DefinitionFile));
                    StoreReport(zip, report);
                    zip.Save();

                    GameData.Definition = definition;
                    GameData.Definition.Compile();
                }
            } finally {
                if (exdPack != null)
                {
                    exdPack.KeepInMemory = exdOldKeepInMemory;
                }
                if (tempPath != null)
                {
                    try {
                        Directory.Delete(tempPath, true);
                    } catch {
                        Console.Error.WriteLine("Failed to delete temporary directory {0}.", tempPath);
                    }
                }
            }
            return(report);
        }
예제 #5
0
        public void TestInUseMove()
        {
            const Boolean recursive = true;

#if SHORT_SOURCE
            var tempPathFilename1 = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), System.IO.Path.GetRandomFileName());
            System.IO.Directory.CreateDirectory(tempPathFilename1);
            Assert.IsTrue(System.IO.Directory.Exists(Path.GetFullPath(tempPathFilename1)));
            var tempPathFilename2 = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), System.IO.Path.GetRandomFileName());
            System.IO.Directory.CreateDirectory(tempPathFilename2);
            Assert.IsTrue(System.IO.Directory.Exists(System.IO.Path.GetFullPath(tempPathFilename2)));
            try
            {
                using (
                    var writer = System.IO.File.CreateText(System.IO.Path.Combine(tempPathFilename2, "TestInUseMove")))
                {
                    string destinationPath =
                        System.IO.Path.GetFullPath(System.IO.Path.Combine(tempPathFilename1, System.IO.Path.GetFileName(tempPathFilename2)));
                    System.IO.Directory.Move(tempPathFilename2, destinationPath);
                    Assert.IsTrue(System.IO.Directory.Exists(System.IO.Path.GetFullPath(tempPathFilename1)));
                    Assert.IsFalse(System.IO.Directory.Exists(System.IO.Path.GetFullPath(tempPathFilename2)));
                    Assert.IsTrue(System.IO.Directory.Exists(destinationPath));
                }
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                Directory.Delete(tempPathFilename1, recursive);
                Directory.Delete(tempPathFilename2, recursive);
            }
#endif
            Assert.Throws <IOException>(() => {
                var tempLongPathFilename1 = uncDirectory.Combine(Pri.LongPath.Path.GetRandomFileName());
                tempLongPathFilename1.CreateDirectory();
                Assert.IsTrue(tempLongPathFilename1.GetFullPath().Exists());
                var tempLongPathFilename2 = uncDirectory.Combine(Pri.LongPath.Path.GetRandomFileName());
                tempLongPathFilename2.CreateDirectory();
                Assert.IsTrue(tempLongPathFilename2.GetFullPath().Exists());

                try {
                    using (var writer = Pri.LongPath.File.CreateText(tempLongPathFilename2.Combine("TestInUseMove"))) {
                        var destinationPath = tempLongPathFilename1.Combine(tempLongPathFilename2.GetFileName()).GetFullPath();
                        Pri.LongPath.Directory.Move(tempLongPathFilename2, destinationPath);
                        Assert.IsTrue(tempLongPathFilename1.GetFullPath().Exists());
                        Assert.IsFalse(tempLongPathFilename2.GetFullPath().Exists());
                        Assert.IsTrue(destinationPath.Exists());
                    }
                }
                finally {
                    Pri.LongPath.Directory.Delete(tempLongPathFilename1, recursive);
                    Pri.LongPath.Directory.Delete(tempLongPathFilename2, recursive);
                }
            });
        }
예제 #6
0
        public void DeleteIndex(string indexName)
        {
            var indexFolder = Path.Combine(_rootPath, indexName);

            if (Directory.Exists(indexFolder))
            {
                Directory.Delete(indexFolder, true);
            }
        }
예제 #7
0
파일: Save.cs 프로젝트: Epita13/Ollopa_main
    public static void DeleteSave(string saveName)
    {
        InitDirectoriesSave();
        string savePath = Path.Combine(savesPath, saveName);

        if (Directory.Exists(savePath))
        {
            Directory.Delete(savePath, true);
        }
    }
예제 #8
0
        public bool DeleteAll()
        {
            if (!this.Exists())
            {
                return(false);
            }

            D.Delete(this.FullName, true);
            return(true);
        }
예제 #9
0
        private void Update()
        {
            _config = new FileSystemActions.config
            {
                downloaded               = true,
                appPath                  = _appPath,
                backupPath               = _backupPath,
                updatesPath              = _updatesPath,
                deleteUpdateProgressExe  = false,
                replaceUpdateProgressExe = false
            };

#if DEBUG
            Report(_config.ToString());
#endif

            FileSystemActions action = new FileSystemActions
            {
                Config = _config,
                Report = _report
            };

            if (!action.BackUp())
            {
                Directory.Delete(_backupPath, true);
                _report("There was a problem creating backup.");
                return;
            }

            _report("Backup successfully created.\nUpdating application files.");
            _disable(Abort);
            if (!action.Update())
            {
                if (!action.Rollback())
                {
                    _report("Fatal error: Application not backed up correctly. It may need reinstallation.");
                    _rollback = false;
                    _fatal    = true;
                }
                if (!string.IsNullOrEmpty(_rollbackExe))
                {
                    _info           = new ProcessStartInfo(_rollbackExe);
                    _info.Arguments = _argv;
                    _rollback       = true;
                }
                _finish();
                return;
            }
            //clear backup files and downloaded updates
            _report("Deleting leftover files");
            bool filesUpdated = action.Clean();
            _finish();
            _report("Application successfully updated.");
        }
 private void CleanupFiles()
 {
     try
     {
         Directory.Delete(TestFolder, true);
     }
     catch
     {
         return;
     }
 }
예제 #11
0
        ///// <summary>
        ///// 分词API  //http://zhannei.baidu.com/api/customsearch/keywords?title=群主可撤回消息,QQ9.0去广告本地SVIP绿色精简优化版
        ///// http://api.pullword.com
        ///// </summary>
        //public static HttpClient ApiClient { get; set; } = new HttpClient() { BaseAddress = new Uri("http://api.pullword.com") };

        #endregion Config

        #region 创建索引

        /// <summary>
        /// 创建索引,如果索引库存在则刷新索引
        /// </summary>
        /// <param name="dataSource"></param>
        /// <returns></returns>
        public static void CreateIndex(IQueryable <Post> dataSource)
        {
            if (string.IsNullOrEmpty(IndexPath))
            {
                throw new Exception("未设置索引文件夹路径,参数名:" + IndexPath);
            }
            string dir = IndexPath;

            #region 创建索引前尝试删除索引文件夹

            try
            {
                Directory.Delete(dir, true);
            }
            catch (Exception e)
            {
                LogManager.Debug("尝试删除索引文件夹失败!", e.Message);
            }

            #endregion 创建索引前尝试删除索引文件夹

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            if (File.Exists(Path.Combine(dir, "segments.gen")))
            {
                IncreaseIndex();
                return;
            }
            string indexPath = dir;                                                                                   //注意和磁盘上文件夹的大小写一致,否则会报错。将创建的分词内容放在该目录下。
            using (FSDirectory directory = FSDirectory.Open(new DirectoryInfo(indexPath), new NativeFSLockFactory())) //指定索引文件(打开索引目录) FS指的是就是FileSystem
            {
                bool isUpdate = IndexReader.IndexExists(directory);                                                   //IndexReader:对索引进行读取的类。该语句的作用:判断索引库文件夹是否存在以及索引特征文件是否存在。
                lock (LockObj)
                {
                    using (var writer = new IndexWriter(directory, new PanGuAnalyzer(), !isUpdate, IndexWriter.MaxFieldLength.UNLIMITED)) //!向索引库中写索引。这时在这里加锁。
                    {
                        foreach (Post item in dataSource.AsParallel())
                        {
                            item.Content = item.Content.RemoveHtml();
                            try
                            {
                                writer.AddDocument(EntityToDocument(item));
                            }
                            catch (IOException e)
                            {
                                Console.WriteLine(e);
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
        public async Task Start()
        {
            string directory = await GetInstallationDirectory();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (File.Exists("SaintCoinach.History.zip"))
            {
                File.Delete("SaintCoinach.History.zip");
            }

            // Unzip definitions
            if (Directory.Exists("./Definitions/"))
            {
                Directory.Delete("./Definitions/", true);
            }

            ZipFile.ExtractToDirectory("./Modules/SaintCoinach/Definitions.zip", "./Definitions/");

            // TODO get language from language service?
            ARealmReversed realm = new ARealmReversed(directory, Language.English);

            try
            {
                if (!realm.IsCurrentVersion)
                {
                    realm.Update(true, this);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(@"Failed to update Saint Coinach", ex);
            }

            Log.Write("Reading data", @"Saint Coinach");

            this.Items                  = this.Load <IItem, Item, ItemWrapper>(realm);
            this.Races                  = this.Load <IRace, Race, RaceWrapper>(realm);
            this.Tribes                 = this.Load <ITribe, Tribe, TribeWrapper>(realm);
            this.Dyes                   = this.Load <IDye, Stain, DyeWrapper>(realm);
            this.BaseNPCs               = this.Load <INpcBase, ENpcBase, NpcBaseWrapper>(realm);
            this.Territories            = this.Load <ITerritoryType, TerritoryType, TerritoryTypeWrapper>(realm);
            this.Weathers               = this.Load <IWeather, Weather, WeatherWrapper>(realm);
            this.CharacterMakeCustomize = this.Load <ICharaMakeCustomize, CharaMakeCustomize, CharacterMakeCustomizeWrapper>(realm);
            this.CharacterMakeTypes     = this.Load <ICharaMakeType, CharaMakeType, CharacterMakeTypeWrapper>(realm);
            this.ResidentNPCs           = this.Load <INpcResident, ENpcResident, NpcResidentWrapper>(realm);
            this.Titles                 = this.Load <ITitle, Title, TitleWrapper>(realm);
            this.Statuses               = this.Load <IStatus, Status, StatusWrapper>(realm);

            Log.Write("Finished Reading data", @"Saint Coinach");
            Log.Write("Initialization took " + sw.ElapsedMilliseconds + "ms", @"Saint Coinach");
        }
예제 #13
0
        private static void HandleBackup(int localPort, IPAddress remoteBackupIp, int remoteBackupPort)
        {
            var localIp = IpAddressUtils.GetLocal();
            var local   = new IPEndPoint(localIp, localPort);
            var remote  = new IPEndPoint(remoteBackupIp, remoteBackupPort);

            using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(local);
            socket.Connect(remote);

            var buffer = new byte[256000];

            socket.SendCompletelyWithEof(Array.Empty <byte>().AsSpan());
            var backupData = socket.ReceiveUntilEof(buffer).To <BackupData>();

            lock (Mutex)
            {
                _lastTree  = backupData.Tree;
                _timestamp = backupData.Timestamp ?? new Timestamp();
                if (_lastTree == null)
                {
                    return;
                }

                if (_pathBuilder.TryGetPrefixedPath(_lastTree, _lastTree.Id, out var rootPath, out _))
                {
                    if (Directory.Exists(rootPath))
                    {
                        Directory.Delete(rootPath, true);
                    }
                }

                foreach (var(id, data) in backupData.Files)
                {
                    if (!_pathBuilder.TryGetPrefixedPath(_lastTree, id, out var path, out _))
                    {
                        continue;
                    }

                    var directory = Path.GetDirectoryName(path);
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    using var file = File.Create(path);
                    file.Write(data);
                    Console.WriteLine($"Loaded file with ID {id} of size {data.Length}.");
                }
            }

            Console.WriteLine("Backup finished.");
        }
예제 #14
0
        public void Visit(InitializeCommand command)
        {
            if (!TryGetPrefixedPathTo(_root.Id, out var path))
            {
                return;
            }

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
예제 #15
0
        public void Teardown()
        {
            if (File.Exists(_filePath))
            {
                File.Delete(_filePath);
            }

            if (Directory.Exists(_directoryPath))
            {
                Directory.Delete(_directoryPath, true);
            }
        }
예제 #16
0
 //TODO add option to delete empty dirs
 public static void ProcessDirectory(string startLocation)
 {
     foreach (var directory in Directory.GetDirectories(startLocation))
     {
         ProcessDirectory(directory);
         if (Directory.GetFiles(directory).Length == 0 &&
             Directory.GetDirectories(directory).Length == 0)
         {
             Directory.Delete(directory, false);
         }
     }
 }
예제 #17
0
        public void BaselineTestCreateDirectory()
        {
            var tempPath = Path.Combine(uncDirectory, Pri.LongPath.Path.GetRandomFileName());
            var di       = Directory.CreateDirectory(tempPath);

            try {
                Assert.IsNotNull(di);
                Assert.IsTrue(Directory.Exists(tempPath));
            }
            finally {
                Directory.Delete(tempPath);
            }
        }
        public bool Delete(string key)
        {
            var path = ComputePath(key);

            if (IsDirectory(path))
            {
                IODirectory.Delete(path, true);
            }

            IOFile.Delete(path);

            return(true);
        }
예제 #19
0
 private void DeleteIndexFolder()
 {
     try
     {
         if (Directory.Exists(SearchIndexFolder))
         {
             Directory.Delete(SearchIndexFolder, true);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
예제 #20
0
 /// <summary>
 /// Удаляет текущий каталог.
 /// </summary>
 public override void delete()
 {
     for (int i = 0; i < dirList.Count; i++)
     {
         try
         {
             ClassDir.Delete(dirList[i], true);
             System.IO.File.Delete(dirList[i]);
             messenger(string.Format("Обьект {0} был удален.\n", dirList[i]));
         }
         catch (Exception e) { throw e; }
     }
     dirList.Clear();
 }
        public void Init()
        {
            var dir = Path.Combine(CurrentAssemblyDirectory, "TestData");

            if (Directory.Exists(dir))
            {
                Directory.GetDirectories("", "", SearchOption.AllDirectories);
                Directory.Delete(dir, true);
            }
            Directory.CreateDirectory(dir);
            Directory.CreateDirectory(Path.Combine(dir, "TempStorageDirectoryTests"));
            Directory.CreateDirectory(Path.Combine(dir, "TempStorageDirectoryTests", "RealStorage"));
            Directory.CreateDirectory(Path.Combine(dir, "TempStorageDirectoryTests", "TempStorage"));
        }
예제 #22
0
        private void RecursiveDeleteEmptyDirectories(string dir, bool importfolder)
        {
            try
            {
                if (string.IsNullOrEmpty(dir))
                {
                    return;
                }
                if (!Directory.Exists(dir))
                {
                    return;
                }
                if (IsDirectoryEmpty(dir))
                {
                    if (importfolder)
                    {
                        return;
                    }
                    try
                    {
                        Directory.Delete(dir);
                    }
                    catch (Exception ex)
                    {
                        if (ex is DirectoryNotFoundException || ex is FileNotFoundException)
                        {
                            return;
                        }
                        logger.Warn("Unable to DELETE directory: {0} Error: {1}", dir,
                                    ex);
                    }
                    return;
                }

                // If it has folder, recurse
                foreach (string d in Directory.EnumerateDirectories(dir))
                {
                    RecursiveDeleteEmptyDirectories(d, false);
                }
            }
            catch (Exception e)
            {
                if (e is FileNotFoundException || e is DirectoryNotFoundException)
                {
                    return;
                }
                logger.Error($"There was an error removing the empty directory: {dir}\r\n{e}");
            }
        }
        protected void DoIndex()
        {
            if (Directory.Exists(IdxDir))
            {
                Directory.Delete(IdxDir, true);
            }
            _logger.Info("Загрузка синонимов из БД...");
            IList <ProductSynonym> synonyms;

            using (var session = SessionHelper.GetSessionFactory().OpenSession()) {
                synonyms = session.Query <ProductSynonym>().Where(s => s.Synonym != null).ToList();
            }
            _logger.InfoFormat("Загрузили {0} синонимов", synonyms.Count());
            DoIndex(synonyms, false, true);
        }
예제 #24
0
        public void Visit(DeleteCommand command)
        {
            if (!TryGetPrefixedPathTo(command.NodeId, out var path))
            {
                return;
            }

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            else if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
예제 #25
0
 /// <summary>
 /// Удаляет текущий каталог.
 /// </summary>
 public override void delete()
 {
     for (int i = 0; i < dirList.Count; i++)
     {
         try
         {
             ClassDir.Delete(dirList[i], true);
             if (Messang != null)
             {
                 Messang(this, new MyEvenArgs(string.Format("Каталог '{0}' удален.", dirList[i])));
             }
         }
         catch { }
     }
     dirList.Clear();
 }
예제 #26
0
        private static async Task <int> Execute()
        {
            try
            {
                if (Directory.Exists(DestPath))
                {
                    Directory.Delete(DestPath, true);
                }
                Directory.CreateDirectory(DestPath);
            }
            catch (Exception e)
            {
                logger.Error(e, $"Could not create destination directory {DestPath} due to an unexpected {e.GetType()}: {e.Message}");
                return(-2);
            }

            if (!forceOverwriteDCS && (await clientApi.GetTitle(destTitleNumber)) != null)
            {
                logger.Warn($"Destination title {destTitleNumber} already exists in DCS. Use -force to overwrite");
                return(0);
            }

            var res = await DownloadSource();

            if (res != 0)
            {
                return(res);
            }

            res = Synthesize();
            if (res != 0)
            {
                return(res);
            }

            if (!skipUploadToArchive)
            {
                return(await UploadDestination());
            }
            else
            {
                logger.Info($"Skipping upload of title {destTitleNumber} to DCSArchive");
                return(0);
            }
        }
예제 #27
0
    /// <summary>
    ///     Deletes a directory, optionally also doing a recursive delete.
    /// </summary>
    /// <param name="path">The path of the directory.</param>
    /// <param name="recursive">
    ///     If set to <see langword="true" />, does a recursive delete. This is <see langword="false" /> by
    ///     default.
    /// </param>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" />
    ///     in Visual Basic).
    /// </exception>
    public void Delete(
        string path,
        bool recursive = false)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        if (recursive)
        {
            FSDir.Delete(
                path,
                true);
        }
        else
        {
            FSDir.Delete(path);
        }
    }
예제 #28
0
        private static void ScanADirNew(string directory)
        {
            _bgw.ReportProgress(0, new bgwText("Scanning Dir : " + directory));
            DirectoryInfo di = new DirectoryInfo(directory);

            FileInfo[] fi = di.GetFiles();

            _bgw.ReportProgress(0, new bgwRange2Visible(true));
            _bgw.ReportProgress(0, new bgwSetRange2(fi.Count()));

            for (int j = 0; j < fi.Count(); j++)
            {
                if (_bgw.CancellationPending)
                {
                    return;
                }

                FileInfo f = fi[j];
                _bgw.ReportProgress(0, new bgwValue2(j));
                _bgw.ReportProgress(0, new bgwText2(f.Name));

                ScanAFile(f);
            }

            DirectoryInfo[] childdi = di.GetDirectories();
            foreach (DirectoryInfo d in childdi)
            {
                if (_bgw.CancellationPending)
                {
                    return;
                }
                ScanADirNew(d.FullName);
            }

            if (directory == "ToSort")
            {
                return;
            }
            if (IsDirectoryEmpty(directory))
            {
                Directory.Delete(directory);
            }
        }
예제 #29
0
 /// <summary>
 /// Удаляет заданный каталог.
 /// </summary>
 public void delete()
 {
     if (SDirectory.Exists(dname) & dname.Length <= 260)//проверка на существование директории и корректности имени
     {
         try
         {
             SDirectory.Delete(dname, true);                //удаление дирректории
             dname = null;                                  //переопределение рабочего каталога
         }
         catch (Exception e)                                //обработка исключений для удаления
         {
             LogForOperations("Удаление папки", e.Message); //запись ошибки в лог(если есть)
             throw e;
         }
     }
     else
     {
         LogForOperations("Удаление папки", "папки не существует либо имя папки превышает 260 символов");//запись ошибки в лог(если не выполнилась проверка)
     }
 }
예제 #30
0
        public void TearDown()
        {
            try {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
            catch (Exception e) {
                Trace.WriteLine("Exception {0} deleting \"filePath\"", e.ToString());

                throw;
            }
            finally {
                if (Directory.Exists(directory))
                {
                    Directory.Delete(directory, true);
                }
            }
        }