本文整理汇总了C#中FileLocator.GetDirectoryFromPath方法的典型用法代码示例。如果您正苦于以下问题:C# FileLocator.GetDirectoryFromPath方法的具体用法?C# FileLocator.GetDirectoryFromPath怎么用?C# FileLocator.GetDirectoryFromPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileLocator
的用法示例。
在下文中一共展示了FileLocator.GetDirectoryFromPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiskImageFile
/// <summary>
/// Initializes a new instance of the DiskImageFile class.
/// </summary>
/// <param name="fileLocator">An object to open the file and any extents</param>
/// <param name="file">The file name</param>
/// <param name="access">The type of access desired</param>
internal DiskImageFile(FileLocator fileLocator, string file, FileAccess access)
{
_access = access;
FileAccess fileAccess = FileAccess.Read;
FileShare fileShare = FileShare.Read;
if (_access != FileAccess.Read)
{
fileAccess = FileAccess.ReadWrite;
fileShare = FileShare.None;
}
Stream fileStream = null;
try
{
fileStream = fileLocator.Open(file, FileMode.Open, fileAccess, fileShare);
LoadDescriptor(fileStream);
// For monolithic disks, keep hold of the stream - we won't try to use the file name
// from the embedded descriptor because the file may have been renamed, making the
// descriptor out of date.
if (_descriptor.CreateType == DiskCreateType.StreamOptimized || _descriptor.CreateType == DiskCreateType.MonolithicSparse)
{
_monolithicStream = fileStream;
_ownsMonolithicStream = Ownership.Dispose;
fileStream = null;
}
}
finally
{
if (fileStream != null)
{
fileStream.Dispose();
}
}
_fileLocator = fileLocator.GetRelativeLocator(fileLocator.GetDirectoryFromPath(file));
}
示例2: DiskImageFile
internal DiskImageFile(FileLocator locator, string path, Stream stream, Ownership ownsStream)
: this(stream, ownsStream)
{
_fileLocator = locator.GetRelativeLocator(locator.GetDirectoryFromPath(path));
_fileName = locator.GetFileFromPath(path);
}
示例3: DiskImageFile
internal DiskImageFile(FileLocator locator, string path, FileAccess access)
{
FileShare share = access == FileAccess.Read ? FileShare.Read : FileShare.None;
_fileStream = locator.Open(path, FileMode.Open, access, share);
_ownsStream = Ownership.Dispose;
_fileLocator = locator.GetRelativeLocator(locator.GetDirectoryFromPath(path));
_fileName = locator.GetFileFromPath(path);
Initialize();
}