public LuceneDotNetHowToExamplesFacade deleteIndex(string indexDirectory = null) { if (indexDirectory != null) { IndexDirectoryInfo = new DirectoryInfo(indexDirectory); } if (IndexDirectoryInfo == null) { throw new Exception("Index directory not specified"); } if (IndexDirectoryInfo.Exists == false) { return(this); } foreach (var fileInfo in IndexDirectoryInfo.GetFiles()) { fileInfo.Delete(); } IndexDirectoryInfo.Delete(); trace("Deleted existing index at {0}", IndexDirectoryInfo.FullName); // must make new object as the old one knows it was deleted and will cause an error later IndexDirectoryInfo = new DirectoryInfo(IndexDirectoryInfo.FullName); return(this); }
public void DeleteIndex(bool DeleteDirectory) { Close(); if (IndexDirectoryInfo == null) throw new Exception("Index directory not specified"); if (IndexDirectoryInfo.Exists == false) return; foreach (var fileInfo in IndexDirectoryInfo.GetFiles()) { fileInfo.Delete(); } if (DeleteDirectory) { IndexDirectoryInfo.Delete(); } trace("Deleted existing index at {0}", IndexDirectoryInfo.FullName); // must make new object as the old one knows it was deleted and will cause an error later IndexDirectoryInfo = new DirectoryInfo(IndexDirectoryInfo.FullName); }