FileFormatUtil
FileFormatUtil class
提供处理文件格式的实用方法,例如检测文件格式 或将文件扩展名转换为/从文件格式枚举。
要了解更多信息,请访问检测文件格式并检查格式兼容性文档文章。
public static class FileFormatUtil
方法
姓名 | 描述 |
---|---|
static ContentTypeToLoadFormat(string) | 将 IANA 内容类型转换为加载格式枚举值。 |
static ContentTypeToSaveFormat(string) | 将 IANA 内容类型转换为保存格式枚举值。 |
static DetectFileFormat(Stream) | 检测并返回有关存储在流中的文档格式的信息。 |
static DetectFileFormat(string) | 检测并返回有关存储在磁盘文件中的文档格式的信息。 |
static ExtensionToSaveFormat(string) | 将文件扩展名转换为SaveFormat 值. |
static ImageTypeToExtension(ImageType) | 将 Aspose.Words 图像类型枚举值转换为文件扩展名。返回的扩展名是一个以点开头的小写字符串。 |
static LoadFormatToExtension(LoadFormat) | 将加载格式枚举值转换为文件扩展名。返回的扩展名是一个以点开头的小写字符串。 |
static LoadFormatToSaveFormat(LoadFormat) | 转换LoadFormat 价值SaveFormat 如果可能的话,值。 |
static SaveFormatToExtension(SaveFormat) | 将保存格式枚举值转换为文件扩展名。返回的扩展名是一个以点开头的小写字符串。 |
static SaveFormatToLoadFormat(SaveFormat) | 转换SaveFormat 价值LoadFormat 如果可能的话,值。 |
例子
展示如何检测 html 文件中的编码。
FileFormatInfo info = FileFormatUtil.DetectFileFormat(MyDir + "Document.html");
Assert.AreEqual(LoadFormat.Html, info.LoadFormat);
// 仅当我们为 html 文档创建 FileFormatInfo 对象时才使用 Encoding 属性。
Assert.AreEqual("Western European (Windows)", info.Encoding.EncodingName);
Assert.AreEqual(1252, info.Encoding.CodePage);
也可以看看
- 命名空间 Aspose.Words
- 部件 Aspose.Words