📄 indexfiles.cs
字号:
//using System;
//using System.IO;
//using Lucene.Net.Analysis.Standard;
//using Lucene.Net.Documents;
//using Lucene.Net.Index;
//
//namespace dotLucene.inAction.Basic
//{
//
// /// <summary>
// /// Summary description for Class1.
// /// </summary>
// internal class IndexFiles
// {
// [STAThread]
// public static void Main(String[] args)
// {
// String usage = typeof (IndexFiles) + " <root_directory>";
// if (args.Length == 0)
// {
// Console.Error.WriteLine("Usage: " + usage);
// Environment.Exit(1);
// }
//
// DateTime start = DateTime.Now;
// try
// {
// IndexWriter writer = new IndexWriter("index", new StandardAnalyzer(), true);
// IndexDirectory(writer, new FileInfo("hello"));
//
// writer.Optimize();
// writer.Close();
//
// DateTime end = DateTime.Now;
//
// Console.Out.Write(end.Ticks - start.Ticks);
// Console.Out.WriteLine(" total millindexSearchereconds");
// }
// catch (IOException e)
// {
// Console.Out.WriteLine(" caught a " + e.GetType() + "\n with message: " + e.Message);
// }
// }
//
// public static void IndexDirectory(IndexWriter writer, FileInfo file)
// {
// if (Directory.Exists(file.FullName))
// {
// String[] files = Directory.GetFileSystemEntries(file.FullName);
// // an IO error could occur
// if (files != null)
// {
// for (int i = 0; i < files.Length; i++)
// {
// IndexDirectory(writer, new FileInfo(files[i]));
// }
// }
// }
// else if (file.Extension == ".txt")
// {
// IndexFile(file, writer);
// }
// }
//
// private static void IndexFile(FileInfo file, IndexWriter writer)
// {
// Console.Out.WriteLine("adding " + file);
// try
// {
// Document doc = new Document();
//
// doc.Add(Field.Keyword("filename", file.FullName));
//
// // System.IO.FileStream is_Renamed = new System.IO.FileStream(file.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
// // System.IO.StreamReader reader = new System.IO.StreamReader(new System.IO.StreamReader(is_Renamed, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(is_Renamed, System.Text.Encoding.Default).CurrentEncoding);
// doc.Add(Field.Text("contents", new StreamReader(file.FullName)));
//
// writer.AddDocument(doc);
// }
// // at least on windows, some temporary files raindexSearchere thindexSearcher exception with an "access denied" message
// // checking if the file can be read doesn't help
// catch (FileNotFoundException fnfe)
// {
//
// }
// }
// }
//}
//
//
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -