本文整理匯總了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));
}