Class FilenameHelper
- Namespace
- VisioForge.Core.Helpers
- Assembly
- VisioForge.Core.dll
Provides utility methods for working with file names, extensions, and paths.
public static class FilenameHelperInheritance
Inherited Members
Methods
ChangeFileExt(string, string)
Changes the file extension of the specified file name to a new extension.
public static string ChangeFileExt(string filename, string ext)Parameters
filenamestring-
The original file name whose extension will be changed.
extstring-
The new extension to apply (should include the period, e.g., ".txt").
Returns
- string
-
The file name with the new extension, or the original file name if no extension was found.
GetFileExt(string)
Gets the file extension from the specified file name, including the period.
public static string GetFileExt(string fileName)Parameters
fileNamestring-
The file name from which to extract the extension.
Returns
- string
-
The file extension including the period (e.g., ".txt"), or an empty string if no extension is found or an error occurs.
IsAudioFile(string)
Determines whether the specified file name represents an audio file based on its extension.
public static bool IsAudioFile(string filename)Parameters
filenamestring-
The file name to check.
Returns
- bool
-
trueif the file extension matches common audio formats (WAV, MP3, OGG, M4A, FLAC, OPUS, SPEEX, WMA); otherwise,false.
IsImageFile(string)
Determines whether the specified file name represents an image file based on its extension.
public static bool IsImageFile(string filename)Parameters
filenamestring-
The file name to check.
Returns
- bool
-
trueif the file extension matches common image formats (BMP, JPG, JPEG, GIF, PNG, TIF, TIFF); otherwise,false.
SafeCreateFileUri(string)
Creates a Uri object from the specified file name, safely handling both absolute and relative paths.
public static Uri SafeCreateFileUri(string fileName)Parameters
fileNamestring-
The file name or path to convert to a URI. Can be either an absolute or relative path.