本文整理汇总了C#中System.IO.Directory.GetEntryByName方法的典型用法代码示例。如果您正苦于以下问题:C# Directory.GetEntryByName方法的具体用法?C# Directory.GetEntryByName怎么用?C# Directory.GetEntryByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Directory
的用法示例。
在下文中一共展示了Directory.GetEntryByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveFileFromDirectory
private static void RemoveFileFromDirectory(Directory dir, File file, string name)
{
List<string> aliases = new List<string>();
DirectoryEntry dirEntry = dir.GetEntryByName(name);
if (dirEntry.Details.FileNameNamespace == FileNameNamespace.Dos
|| dirEntry.Details.FileNameNamespace == FileNameNamespace.Win32)
{
foreach (var fnStream in file.GetStreams(AttributeType.FileName, null))
{
var fnr = fnStream.GetContent<FileNameRecord>();
if ((fnr.FileNameNamespace == FileNameNamespace.Win32 || fnr.FileNameNamespace == FileNameNamespace.Dos)
&& fnr.ParentDirectory.Value == dir.MftReference.Value)
{
aliases.Add(fnr.FileName);
}
}
}
else
{
aliases.Add(name);
}
foreach (var alias in aliases)
{
DirectoryEntry de = dir.GetEntryByName(alias);
dir.RemoveEntry(de);
}
}
示例2: GetDirectoryEntry
private DirectoryEntry GetDirectoryEntry(Directory dir, string[] pathEntries, int pathOffset)
{
DirectoryEntry entry;
if (pathEntries.Length == 0)
{
return dir.DirectoryEntry;
}
else
{
entry = dir.GetEntryByName(pathEntries[pathOffset]);
if (entry != null)
{
if (pathOffset == pathEntries.Length - 1)
{
return entry;
}
else if ((entry.Details.FileAttributes & FileAttributes.Directory) != 0)
{
return GetDirectoryEntry(GetDirectory(entry.Reference), pathEntries, pathOffset + 1);
}
else
{
throw new IOException(string.Format(CultureInfo.InvariantCulture, "{0} is a file, not a directory", pathEntries[pathOffset]));
}
}
else
{
return null;
}
}
}
示例3: VerifyWellKnownFilesExist
private void VerifyWellKnownFilesExist()
{
Directory rootDir = new Directory(_context, _context.Mft.GetRecord(MasterFileTable.RootDirIndex, false));
DirectoryEntry extendDirEntry = rootDir.GetEntryByName("$Extend");
if (extendDirEntry == null)
{
ReportError("$Extend does not exist in root directory");
Abort();
}
Directory extendDir = new Directory(_context, _context.Mft.GetRecord(extendDirEntry.Reference));
DirectoryEntry objIdDirEntry = extendDir.GetEntryByName("$ObjId");
if (objIdDirEntry == null)
{
ReportError("$ObjId does not exist in $Extend directory");
Abort();
}
// Stash ObjectIds
_context.ObjectIds = new ObjectIds(new File(_context, _context.Mft.GetRecord(objIdDirEntry.Reference)));
DirectoryEntry sysVolInfDirEntry = rootDir.GetEntryByName("System Volume Information");
if (sysVolInfDirEntry == null)
{
ReportError("'System Volume Information' does not exist in root directory");
Abort();
}
////Directory sysVolInfDir = new Directory(_context, _context.Mft.GetRecord(sysVolInfDirEntry.Reference));
}