本文整理汇总了C#中FileName.GetDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C# FileName.GetDisplayName方法的具体用法?C# FileName.GetDisplayName怎么用?C# FileName.GetDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName.GetDisplayName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenFile
internal SparseStream OpenFile(FileName name, FileMode mode, FileAccess fileAccess)
{
if (mode == FileMode.Append || mode == FileMode.Truncate)
{
throw new NotImplementedException();
}
long fileId = FindEntry(name);
bool exists = fileId != -1;
if (mode == FileMode.CreateNew && exists)
{
throw new IOException("File already exists");
}
else if (mode == FileMode.Open && !exists)
{
throw new FileNotFoundException("File not found", name.GetDisplayName(_fileSystem.FatOptions.FileNameEncoding));
}
else if ((mode == FileMode.Open || mode == FileMode.OpenOrCreate || mode == FileMode.Create) && exists)
{
SparseStream stream = new FatFileStream(_fileSystem, this, fileId, fileAccess);
if (mode == FileMode.Create)
{
stream.SetLength(0);
}
HandleAccessed(false);
return stream;
}
else if ((mode == FileMode.OpenOrCreate || mode == FileMode.CreateNew || mode == FileMode.Create) && !exists)
{
// Create new file
DirectoryEntry newEntry = new DirectoryEntry(_fileSystem.FatOptions, name, FatAttributes.Archive, _fileSystem.FatVariant);
newEntry.FirstCluster = 0; // i.e. Zero-length
newEntry.CreationTime = _fileSystem.ConvertFromUtc(DateTime.UtcNow);
newEntry.LastWriteTime = newEntry.CreationTime;
fileId = AddEntry(newEntry);
return new FatFileStream(_fileSystem, this, fileId, fileAccess);
}
else
{
// Should never get here...
throw new NotImplementedException();
}
}