FileFormatUtilSaveFormatToExtension Method |
Converts a save format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
Namespace:
Aspose.Words
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntaxpublic static string SaveFormatToExtension(
SaveFormat saveFormat
)
Public Shared Function SaveFormatToExtension (
saveFormat As SaveFormat
) As String
public:
static String^ SaveFormatToExtension(
SaveFormat saveFormat
)
static member SaveFormatToExtension :
saveFormat : SaveFormat -> string
Parameters
- saveFormat
- Type: Aspose.WordsSaveFormat
Return Value
Type:
String
Exceptions
RemarksThe WordML value is converted to ".wml".
The FlatOpc value is converted to ".fopc".
ExamplesShows how to use the FileFormatUtil methods to detect the format of a document without any extension and save it with the correct file extension.
FileStream docStream = File.OpenRead(MyDir + "Word document with missing file extension");
FileFormatInfo info = FileFormatUtil.DetectFileFormat(docStream);
LoadFormat loadFormat = info.LoadFormat;
string fileExtension = FileFormatUtil.LoadFormatToExtension(loadFormat);
SaveFormat saveFormat = FileFormatUtil.ExtensionToSaveFormat(fileExtension);
saveFormat = FileFormatUtil.LoadFormatToSaveFormat(loadFormat);
Document doc = new Document(docStream);
doc.Save(
ArtifactsDir + "File.SaveToDetectedFileFormat" + FileFormatUtil.SaveFormatToExtension(saveFormat));
See Also