本文整理汇总了C#中Directory类的典型用法代码示例。如果您正苦于以下问题:C# Directory类的具体用法?C# Directory怎么用?C# Directory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Directory类属于命名空间,在下文中一共展示了Directory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例6: MapIconUserControl
public MapIconUserControl(Directory directory)
{
this.InitializeComponent();
(this.Content as FrameworkElement).DataContext = this;
Directory = directory;
}
示例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;
}
}
}
}
示例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());
}
示例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;
}
示例10: PendingDirectory
// ReSharper disable once SuggestBaseTypeForParameter
public PendingDirectory(InstallationDirectory installationDirectory, SystemClock clock)
{
_pendingLocation = installationDirectory.GetChildDirectory(LocationExtensions.Pending);
_pendingLocation.EnsureExists();
_clock = clock;
}
示例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);
}
示例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"));
}
示例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();
}
示例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()));
}
示例15: File
public File(Filesystem parent, Directory parentDir, string name, int id)
{
this.parentP = parent;
this.parentDirP = parentDir;
this.nameP = name;
this.idP = id;
}