Document() public static method

Makes a document for a File.

The document has three fields:

  • path--containing the pathname of the file, as a stored, untokenized field;
  • modified--containing the last modified date of the file as a field as created by DateTools; and
  • contents--containing the full contents of the file, as a Reader field;
public static Document ( System f ) : Lucene.Net.Documents.Document
f System
return Lucene.Net.Documents.Document
示例#1
0
 internal static void  IndexDocs(IndexWriter writer, System.IO.FileInfo file)
 {
     // do not try to index files that cannot be read
     // if (file.canRead())  // {{Aroush}} what is canRead() in C#?
     {
         if (System.IO.Directory.Exists(file.FullName))
         {
             System.String[] files = System.IO.Directory.GetFileSystemEntries(file.FullName);
             // an IO error could occur
             if (files != null)
             {
                 for (int i = 0; i < files.Length; i++)
                 {
                     IndexDocs(writer, new System.IO.FileInfo(files[i]));
                 }
             }
         }
         else
         {
             System.Console.Out.WriteLine("adding " + file);
             try
             {
                 writer.AddDocument(FileDocument.Document(file));
             }
             // at least on windows, some temporary files raise this exception with an "access denied" message
             // checking if the file can be read doesn't help
             catch (System.IO.FileNotFoundException fnfe)
             {
                 ;
             }
         }
     }
 }
示例#2
0
        internal static void IndexDocs(IndexWriter writer, FileInfo file)
        {
            Console.Out.WriteLine("adding " + file);

            try
            {
                writer.AddDocument(FileDocument.Document(file));
            }
            catch (FileNotFoundException)
            {
                // At least on Windows, some temporary files raise this exception with an
                // "access denied" message checking if the file can be read doesn't help.
            }
            catch (UnauthorizedAccessException)
            {
                // Handle any access-denied errors that occur while reading the file.
            }
            catch (IOException)
            {
                // Generic handler for any io-related exceptions that occur.
            }
        }