当前位置: 首页>>代码示例>>C#>>正文


C# Directory.ListAll方法代码示例

本文整理汇总了C#中Lucene.Net.Store.Directory.ListAll方法的典型用法代码示例。如果您正苦于以下问题:C# Directory.ListAll方法的具体用法?C# Directory.ListAll怎么用?C# Directory.ListAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Store.Directory的用法示例。


在下文中一共展示了Directory.ListAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Copy

		/// <summary> Copy contents of a directory src to a directory dest.
		/// If a file in src already exists in dest then the
		/// one in dest will be blindly overwritten.
		/// 
		/// <p/><b>NOTE:</b> the source directory cannot change
		/// while this method is running.  Otherwise the results
		/// are undefined and you could easily hit a
		/// FileNotFoundException.
		/// 
		/// <p/><b>NOTE:</b> this method only copies files that look
		/// like index files (ie, have extensions matching the
		/// known extensions of index files).
		/// 
		/// </summary>
		/// <param name="src">source directory
		/// </param>
		/// <param name="dest">destination directory
		/// </param>
		/// <param name="closeDirSrc">if <code>true</code>, call {@link #Close()} method on source directory
		/// </param>
		/// <throws>  IOException </throws>
		public static void  Copy(Directory src, Directory dest, bool closeDirSrc)
		{
			System.String[] files = src.ListAll();
			
			IndexFileNameFilter filter = IndexFileNameFilter.GetFilter();
			
			byte[] buf = new byte[BufferedIndexOutput.BUFFER_SIZE];
			for (int i = 0; i < files.Length; i++)
			{
				
				if (!filter.Accept(null, files[i]))
					continue;
				
				IndexOutput os = null;
				IndexInput is_Renamed = null;
				try
				{
					// create file in dest directory
					os = dest.CreateOutput(files[i]);
					// read current file
					is_Renamed = src.OpenInput(files[i]);
					// and copy to dest directory
					long len = is_Renamed.Length();
					long readCount = 0;
					while (readCount < len)
					{
						int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len?(int) (len - readCount):BufferedIndexOutput.BUFFER_SIZE;
						is_Renamed.ReadBytes(buf, 0, toRead);
						os.WriteBytes(buf, toRead);
						readCount += toRead;
					}
				}
				finally
				{
					// graceful cleanup
					try
					{
						if (os != null)
							os.Close();
					}
					finally
					{
						if (is_Renamed != null)
							is_Renamed.Close();
					}
				}
			}
			if (closeDirSrc)
				src.Close();
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:71,代码来源:Directory.cs

示例2: CheckFiles

 // checks that we can open all files returned by listAll!
 private void CheckFiles(Directory dir)
 {
     foreach (string file in dir.ListAll())
     {
         if (file.EndsWith(IndexFileNames.COMPOUND_FILE_EXTENSION))
         {
             CompoundFileDirectory cfsDir = new CompoundFileDirectory(dir, file, NewIOContext(Random()), false);
             CheckFiles(cfsDir); // recurse into cfs
             cfsDir.Dispose();
         }
         IndexInput @in = null;
         bool success = false;
         try
         {
             @in = dir.OpenInput(file, NewIOContext(Random()));
             success = true;
         }
         finally
         {
             if (success)
             {
                 IOUtils.Close(@in);
             }
             else
             {
                 IOUtils.CloseWhileHandlingException(@in);
             }
         }
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:31,代码来源:TestCompoundFile.cs

示例3: CheckDirectoryFilter

		// LUCENE-1468
		private void  CheckDirectoryFilter(Directory dir)
		{
			System.String name = "file";
			try
			{
				dir.CreateOutput(name).Close();
				Assert.IsTrue(dir.FileExists(name));
				Assert.IsTrue(new System.Collections.ArrayList(dir.ListAll()).Contains(name));
			}
			finally
			{
				dir.Close();
			}
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:15,代码来源:TestDirectory.cs

示例4: CheckDirectoryFilter

 // LUCENE-1468
 private void CheckDirectoryFilter(Directory dir)
 {
     string name = "file";
     try
     {
         dir.CreateOutput(name, NewIOContext(Random())).Dispose();
         Assert.IsTrue(SlowFileExists(dir, name));
         Assert.IsTrue(Arrays.AsList(dir.ListAll()).Contains(name));
     }
     finally
     {
         dir.Dispose();
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:15,代码来源:TestDirectory.cs

示例5: RemoveOldFiles

 private static void RemoveOldFiles(Directory directory, string[] skipFiles, long referenceTimestamp)
 {
     var destinationFiles = directory.ListAll();
     var filesToRemove = destinationFiles.Except(skipFiles);
     foreach (var file in filesToRemove)
     {
         if (directory.FileModified(file) < referenceTimestamp)
         {
             directory.DeleteFile(file);
         }
     }
 }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:12,代码来源:AzureDirectorySynchronizer.cs

示例6: RAMDirectory

 private RAMDirectory(Directory dir, bool closeDir, IOContext context)
     : this()
 {
     foreach (string file in dir.ListAll())
     {
         dir.Copy(this, file, file, context);
     }
     if (closeDir)
     {
         dir.Dispose();
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:RAMDirectory.cs

示例7: GetLastCommitGeneration

 /// <summary>
 /// Get the generation of the most recent commit to the
 /// index in this directory (N in the segments_N file).
 /// </summary>
 /// <param name="directory"> -- directory to search for the latest segments_N file </param>
 public static long GetLastCommitGeneration(Directory directory)
 {
     try
     {
         return GetLastCommitGeneration(directory.ListAll());
     }
     catch (NoSuchDirectoryException)
     {
         return -1;
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:16,代码来源:SegmentInfos.cs


注:本文中的Lucene.Net.Store.Directory.ListAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。