本文整理汇总了C#中Directory类的典型用法代码示例。如果您正苦于以下问题:C# Directory类的具体用法?C# Directory怎么用?C# Directory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Directory类属于命名空间,在下文中一共展示了Directory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ListDirectoryContents
public Directory ListDirectoryContents(string url)
{
Directory dirToReturn = new Directory();
List<string> listOfItems;
listOfItems = RetrieveAllItems(url);
foreach (string item in listOfItems)
{
//if there is no extension found we assume this is a dir
if (System.IO.Path.HasExtension(item) == false)
{
Directory newDir = ListDirectoryContents(url + item + "/");
newDir.url = item;
dirToReturn.dirs.Add(newDir);
}
//if there is an extension we creat a new file object
else if (System.IO.Path.HasExtension(item) == true)
{
File newFile = new File();
newFile.url = item;
dirToReturn.files.Add(newFile);
}
}
return dirToReturn;
}
开发者ID:Sicarius154,项目名称:FtpProgram,代码行数:26,代码来源:FtpConnection.cs
示例2: debugMode
public void debugMode()
{
//初始化全局块组
for (int i = 0; i < Config.GROUPS; i++)
VFS.BLOCK_GROUPS[i] = new BlockGroup(i);
//初始化目录树
VFS.rootDir = new Directory("/", null);
Directory bootDir = new Directory("boot", VFS.rootDir);
Directory etcDir = new Directory("etc", VFS.rootDir);
Directory libDir = new Directory("lib", VFS.rootDir);
Directory homeDir = new Directory("home", VFS.rootDir);
Directory rootDir = new Directory("root", VFS.rootDir);
Directory tempDir = new Directory("temp", VFS.rootDir);
VFS.rootDir.add(bootDir);
VFS.rootDir.add(etcDir);
VFS.rootDir.add(homeDir);
VFS.rootDir.add(libDir);
VFS.rootDir.add(rootDir);
VFS.rootDir.add(tempDir);
File file1 = new File("bashrc", etcDir);
File file2 = new File("shadowsocks", etcDir);
etcDir.add(file1);
etcDir.add(file2);
}
开发者ID:RainsSoft,项目名称:VFS-2,代码行数:27,代码来源:Form1.cs
示例3: SetUp
public override void SetUp()
{
base.SetUp();
Dir = NewDirectory();
FieldName = Random().NextBoolean() ? "field" : ""; // sometimes use an empty string as field name
RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
Document doc = new Document();
Field field = NewStringField(FieldName, "", Field.Store.NO);
doc.Add(field);
List<string> terms = new List<string>();
int num = AtLeast(200);
for (int i = 0; i < num; i++)
{
string s = TestUtil.RandomUnicodeString(Random());
field.StringValue = s;
terms.Add(s);
writer.AddDocument(doc);
}
if (VERBOSE)
{
// utf16 order
terms.Sort();
Console.WriteLine("UTF16 order:");
foreach (string s in terms)
{
Console.WriteLine(" " + UnicodeUtil.ToHexString(s));
}
}
Reader = writer.Reader;
Searcher1 = NewSearcher(Reader);
Searcher2 = NewSearcher(Reader);
writer.Dispose();
}
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:35,代码来源:TestRegexpRandom2.cs
示例4: SetUp
public override void SetUp()
{
base.SetUp();
Dir = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.OmitNorms = true;
Field field = NewField("field", "", customType);
doc.Add(field);
NumberFormatInfo df = new NumberFormatInfo();
df.NumberDecimalDigits = 0;
//NumberFormat df = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ROOT));
for (int i = 0; i < 1000; i++)
{
field.StringValue = i.ToString(df);
writer.AddDocument(doc);
}
Reader = writer.Reader;
writer.Dispose();
Searcher = NewSearcher(Reader);
}
开发者ID:paulirwin,项目名称:lucene.net,代码行数:26,代码来源:TestRegexpRandom.cs
示例5: SetUp
public override void SetUp()
{
base.SetUp();
// we generate aweful regexps: good for testing.
// but for preflex codec, the test can be very slow, so use less iterations.
NumIterations = Codec.Default.Name.Equals("Lucene3x") ? 10 * RANDOM_MULTIPLIER : AtLeast(50);
Dir = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
Document doc = new Document();
Field field = NewStringField("field", "", Field.Store.YES);
doc.Add(field);
Terms = new SortedSet<BytesRef>();
int num = AtLeast(200);
for (int i = 0; i < num; i++)
{
string s = TestUtil.RandomUnicodeString(Random());
field.StringValue = s;
Terms.Add(new BytesRef(s));
writer.AddDocument(doc);
}
TermsAutomaton = BasicAutomata.MakeStringUnion(Terms);
Reader = writer.Reader;
Searcher = NewSearcher(Reader);
writer.Dispose();
}
开发者ID:joyanta,项目名称:lucene.net,代码行数:28,代码来源:TestTermsEnum2.cs
示例6: MapIconUserControl
public MapIconUserControl(Directory directory)
{
this.InitializeComponent();
(this.Content as FrameworkElement).DataContext = this;
Directory = directory;
}
开发者ID:blazemonkey,项目名称:NZSchools,代码行数:7,代码来源:MapIconUserControl.xaml.cs
示例7: VariableGapTermsIndexReader
public VariableGapTermsIndexReader(Directory dir, FieldInfos fieldInfos, String segment, int indexDivisor,
String segmentSuffix, IOContext context)
{
_input =
dir.OpenInput(
IndexFileNames.SegmentFileName(segment, segmentSuffix,
VariableGapTermsIndexWriter.TERMS_INDEX_EXTENSION), new IOContext(context, true));
var success = false;
Debug.Assert(indexDivisor == -1 || indexDivisor > 0);
try
{
_version = ReadHeader(_input);
_indexDivisor = indexDivisor;
if (_version >= VariableGapTermsIndexWriter.VERSION_CHECKSUM)
CodecUtil.ChecksumEntireFile(_input);
SeekDir(_input, _dirOffset);
// Read directory
var numFields = _input.ReadVInt();
if (numFields < 0)
{
throw new CorruptIndexException("invalid numFields: " + numFields + " (resource=" + _input + ")");
}
for (var i = 0; i < numFields; i++)
{
var field = _input.ReadVInt();
var indexStart = _input.ReadVLong();
var fieldInfo = fieldInfos.FieldInfo(field);
try
{
_fields.Add(fieldInfo, new FieldIndexData(indexStart, this));
}
catch (ArgumentException)
{
throw new CorruptIndexException(String.Format("Duplicate Field: {0}, Resource: {1}",
fieldInfo.Name, _input));
}
}
success = true;
}
finally
{
if (indexDivisor > 0)
{
_input.Dispose();
_input = null;
if (success)
{
_indexLoaded = true;
}
}
}
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:60,代码来源:VariableGapTermsIndexReader.cs
示例8: ls
public void ls()
{
Directory racine = new Directory("racine", null, 7);
Directory test = new Directory("test", racine, 7);
racine.listeFile.Add(test);
Assert.AreEqual(racine.listeFile, racine.ls());
}
开发者ID:BaptisteCHVT,项目名称:TestUnitaire,代码行数:7,代码来源:Ls.cs
示例9: Main
public static int Main(string[] args)
{
string directory = args[0];
Tag t = new Tag(0x8,0x80);
Directory d = new Directory();
uint nfiles = d.Load( directory );
if(nfiles == 0) return 1;
//System.Console.WriteLine( "Files:\n" + d.toString() );
// Use a StrictScanner, need to use a reference to pass the C++ pointer to
// MyWatcher implementation
SmartPtrStrictScan sscan = StrictScanner.New();
StrictScanner s = sscan.__ref__();
MyWatcher watcher = new MyWatcher(s);
s.AddTag( t );
bool b = s.Scan( d.GetFilenames() );
if(!b) return 1;
for(int i = 0; i < (int)nfiles; ++i)
{
if( !s.IsKey( d.GetFilenames()[i] ) )
{
System.Console.WriteLine( "File is not DICOM or could not be read: " + d.GetFilenames()[i] );
}
}
System.Console.WriteLine( "Scan:\n" + s.toString() );
System.Console.WriteLine( "success" );
return 0;
}
开发者ID:chris-ondemand3d,项目名称:GDCM,代码行数:33,代码来源:ScanDirectory.cs
示例10: PendingDirectory
// ReSharper disable once SuggestBaseTypeForParameter
public PendingDirectory(InstallationDirectory installationDirectory, SystemClock clock)
{
_pendingLocation = installationDirectory.GetChildDirectory(LocationExtensions.Pending);
_pendingLocation.EnsureExists();
_clock = clock;
}
开发者ID:InfiniteComputingSystems,项目名称:Test,代码行数:8,代码来源:PendingDirectory.cs
示例11: CreateStandard
/// <summary>Creates engine based on provided <paramref name="directoryInfo"/>.</summary>
public static Engine CreateStandard(DirectoryInfo directoryInfo)
{
var directory = new Directory(directoryInfo);
var documentAssembler = new DesignDocumentAssembler(directory);
var designDocumentExtractor = new DesignDocumentExtractor();
return new Engine(designDocumentExtractor, documentAssembler);
}
开发者ID:artikh,项目名称:CouchDude.SchemeManager,代码行数:8,代码来源:Engine.cs
示例12: SetUp
public override void SetUp()
{
base.SetUp();
INDEX_SIZE = AtLeast(2000);
Index = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Index);
RandomGen random = new RandomGen(this, Random());
for (int i = 0; i < INDEX_SIZE; ++i) // don't decrease; if to low the
{
// problem doesn't show up
Document doc = new Document();
if ((i % 5) != 0) // some documents must not have an entry in the first
{
// sort field
doc.Add(NewStringField("publicationDate_", random.LuceneDate, Field.Store.YES));
}
if ((i % 7) == 0) // some documents to match the query (see below)
{
doc.Add(NewTextField("content", "test", Field.Store.YES));
}
// every document has a defined 'mandant' field
doc.Add(NewStringField("mandant", Convert.ToString(i % 3), Field.Store.YES));
writer.AddDocument(doc);
}
Reader = writer.Reader;
writer.Dispose();
Query = new TermQuery(new Term("content", "test"));
}
开发者ID:joyanta,项目名称:lucene.net,代码行数:28,代码来源:TestCustomSearcherSort.cs
示例13: Main
static void Main(string[] args)
{
Component fileSystem = new Directory("Файловая система");
// определяем новый диск
Component diskC = new Directory("Диск С");
// новые файлы
Component pngFile = new File("12345.png");
Component docxFile = new File("Document.docx");
// добавляем файлы на диск С
diskC.Add(pngFile);
diskC.Add(docxFile);
// добавляем диск С в файловую систему
fileSystem.Add(diskC);
// выводим все данные
fileSystem.Print();
Console.WriteLine();
// удаляем с диска С файл
diskC.Remove(pngFile);
// создаем новую папку
Component docsFolder = new Directory("Мои Документы");
// добавляем в нее файлы
Component txtFile = new File("readme.txt");
Component csFile = new File("Program.cs");
docsFolder.Add(txtFile);
docsFolder.Add(csFile);
diskC.Add(docsFolder);
fileSystem.Print();
Console.Read();
}
开发者ID:alexxx0788,项目名称:Patterns_Shapr,代码行数:31,代码来源:Program.cs
示例14: Lucene40DocValuesReader
internal Lucene40DocValuesReader(SegmentReadState state, string filename, string legacyKey)
{
this.State = state;
this.LegacyKey = legacyKey;
this.Dir = new CompoundFileDirectory(state.Directory, filename, state.Context, false);
RamBytesUsed_Renamed = new AtomicLong(RamUsageEstimator.ShallowSizeOf(this.GetType()));
}
开发者ID:paulirwin,项目名称:lucene.net,代码行数:7,代码来源:Lucene40DocValuesReader.cs
示例15: File
public File(Filesystem parent, Directory parentDir, string name, int id)
{
this.parentP = parent;
this.parentDirP = parentDir;
this.nameP = name;
this.idP = id;
}
开发者ID:elfinlazz,项目名称:NSMB-Editor,代码行数:7,代码来源:File.cs
示例16: SetUp
public override void SetUp()
{
base.SetUp();
Document doc;
Rd1 = NewDirectory();
IndexWriter iw1 = new IndexWriter(Rd1, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
doc = new Document();
doc.Add(NewTextField("field1", "the quick brown fox jumps", Field.Store.YES));
doc.Add(NewTextField("field2", "the quick brown fox jumps", Field.Store.YES));
iw1.AddDocument(doc);
iw1.Dispose();
Rd2 = NewDirectory();
IndexWriter iw2 = new IndexWriter(Rd2, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
doc = new Document();
doc.Add(NewTextField("field1", "the fox jumps over the lazy dog", Field.Store.YES));
doc.Add(NewTextField("field3", "the fox jumps over the lazy dog", Field.Store.YES));
iw2.AddDocument(doc);
iw2.Dispose();
this.Ir1 = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(Rd1));
this.Ir2 = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(Rd2));
}
开发者ID:joyanta,项目名称:lucene.net,代码行数:26,代码来源:TestParallelTermEnum.cs
示例17: Write
/// <summary>
/// Save a single segment's info. </summary>
public override void Write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext)
{
string fileName = IndexFileNames.SegmentFileName(si.Name, "", Lucene40SegmentInfoFormat.SI_EXTENSION);
si.AddFile(fileName);
IndexOutput output = dir.CreateOutput(fileName, ioContext);
bool success = false;
try
{
CodecUtil.WriteHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
// Write the Lucene version that created this segment, since 3.1
output.WriteString(si.Version);
output.WriteInt(si.DocCount);
output.WriteByte((sbyte)(si.UseCompoundFile ? SegmentInfo.YES : SegmentInfo.NO));
output.WriteStringStringMap(si.Diagnostics);
output.WriteStringStringMap(CollectionsHelper.EmptyMap<string, string>());
output.WriteStringSet(si.Files);
success = true;
}
finally
{
if (!success)
{
IOUtils.CloseWhileHandlingException(output);
si.Dir.DeleteFile(fileName);
}
else
{
output.Dispose();
}
}
}
开发者ID:joyanta,项目名称:lucene.net,代码行数:37,代码来源:Lucene40SegmentInfoWriter.cs
示例18: File
public File(Directory directory, string filePath)
{
FilePath = filePath;
Directory = directory;
FileExtension = Path.GetExtension(FilePath);
FileName = FilePath.Split(Constants.PathSeparator).Last();
}
开发者ID:fir3pho3nixx,项目名称:test-sharp,代码行数:7,代码来源:File.cs
示例19: getParent
public void getParent()
{
Directory racine = new Directory("racine", null, 7);
Directory test = new Directory("test", racine, 7);
Assert.AreEqual(racine, test.getParent());
// la commande parent ne marche pas dans le programme, c'est pour ça que le test unitaire ne marche pas non plus
}
开发者ID:BaptisteCHVT,项目名称:TestUnitaire,代码行数:7,代码来源:GetParent.cs
示例20: PreFlexRWStoredFieldsWriter
public PreFlexRWStoredFieldsWriter(Directory directory, string segment, IOContext context)
{
Debug.Assert(directory != null);
this.Directory = directory;
this.Segment = segment;
bool success = false;
try
{
FieldsStream = directory.CreateOutput(IndexFileNames.SegmentFileName(segment, "", Lucene3xStoredFieldsReader.FIELDS_EXTENSION), context);
IndexStream = directory.CreateOutput(IndexFileNames.SegmentFileName(segment, "", Lucene3xStoredFieldsReader.FIELDS_INDEX_EXTENSION), context);
FieldsStream.WriteInt(Lucene3xStoredFieldsReader.FORMAT_CURRENT);
IndexStream.WriteInt(Lucene3xStoredFieldsReader.FORMAT_CURRENT);
success = true;
}
finally
{
if (!success)
{
Abort();
}
}
}
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:25,代码来源:PreFlexRWStoredFieldsWriter.cs
注:本文中的Directory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论