Class mmFileUtils

Internal File Utilities class

System.Object
  MarkdownMonster.mmFileUtils
public static class mmFileUtils : object

Class Members

MemberDescription

FOF_ALLOWUNDO

FOF_NOCONFIRMATION

FO_COPY

FO_DELETE

FO_MOVE

FO_RENAME

CopyDirectory

Copies a directory, and its files. Creates the top level directory if it doesn't exist

public static string CopyDirectory(string sourceDirectory,     string targetDirectory,     bool deleteFirst,     bool recursive)

public static string CopyDirectory(DirectoryInfo source,     DirectoryInfo target,     bool deleteFirst,     bool recursive)

CopyFileOrFolder

Uses the Window Shell UI to move files which behaves similar to Explorer behavior warning for errors and supports undo.

public static bool CopyFileOrFolder(string sourceFolder,     string targetFolder,     bool confirmation)

EnsureAssociations

public static void EnsureAssociations(bool force,     bool uninstall)

EnsureBrowserEmulationEnabled

Set Internet Explorer browser compatibility

public static void EnsureBrowserEmulationEnabled(string exename,     bool uninstall)

EnsureSystemPath

public static void EnsureSystemPath(bool uninstall)

FileSizeToString

Returns file size as string with size prefix (bytes, kb, mb)

public static string FileSizeToString(long fileSize)

FindGitClient

Checks to see if

public static string FindGitClient()

FindGitDiffTool

public static string FindGitDiffTool()

FindImageEditor

Tries to find an installed image editor on the system as a default.

public static string FindImageEditor()

FixupDocumentFilename

Method checks for existance of full filename and tries to check for file in the initial startup folder.

public static string FixupDocumentFilename(string file)

GetChecksumFromFile

Creates an MD5 checksum of a file

public static string GetChecksumFromFile(string file)

GetEditorSyntaxFromFileType

Retrieves the editor syntax for a file based on extension for use in the editor

public static string GetEditorSyntaxFromFileType(string filename)

GetEncoding

public static Encoding GetEncoding(string encodingName)

GetEncodingList

Returns a list of encoding display names for use in lists.

public static List GetEncodingList(bool fullList)

GetEncodingName

Gets an encoding name from an Encoding instance

public static string GetEncodingName(Encoding encoding)

GetFileEncoding

Retrieve the file encoding for a given file so we can capture and store the Encoding when writing the file back out after editing.

public static Encoding GetFileEncoding(string srcFile)

GetImageMediaTypeFromFilename

Returns the image media type for a give file extension based on a filename or url passed in.

public static string GetImageMediaTypeFromFilename(string file)

IsImage

Determines if a file is one of the common image extensions "jpg", "png", "gif", "bmp", "jpeg", "jp2", "apng", "tif", "tiff", "heif", "heic", "webp", "raw"

public static bool IsImage(string selectedFullPath,     String[] extraExtensions)

MoveFileOrFolder

Uses the Window Shell UI to move files which behaves similar to Explorer behavior warning for errors and supports undo.

public static bool MoveFileOrFolder(string sourceFolder,     string targetFolder,     bool confirmation)

MoveToRecycleBin

Uses the Windows Shell API to delete files and put them into the recycle bin

public static bool MoveToRecycleBin(string filename)

NormalizeFilenameWithBasePath

Normalizes a potentially relative pathname to a base path name if the exact filename doesn't exist by prepending the base path explicitly.

public static string NormalizeFilenameWithBasePath(string file,     string basePath)

OpenBrowser

Opens the user's default browser explicitly from shell association and passes the URL to the command line. This has more features (like # support) than shell Execute.

public static void OpenBrowser(string url)

OpenGitClient

Opens the configured Git Client in the specified folder

public static bool OpenGitClient(string folder)

OpenImageInImageEditor

Opens an image in the configured image editor

public static bool OpenImageInImageEditor(string imageFileOrUrl)

OpenImageInImageViewer

Opens an image in the configured image viewer. If none is specified uses default image viewer

public static bool OpenImageInImageViewer(string imageFile)

OpenTerminal

Opens the configured image editor. If command can't be executed the function returns false

public static bool OpenTerminal(string folder)

OpenTextFile

Helper to use instead ReadAllText when using UI open operations. This dialog uses most permissive READ permissions and also captures errors and displays a MessageBox on failure.

public static string OpenTextFile(string filename)

OptimizeImage

Optimizes an image. Runs asynchronous in the background and it's not fast so don't rely on the file results immediately.

public static void OptimizeImage(string imageFilename,     int imageQuality,     Action onComplete)

OptimizePngImage

Tries to optimize png images in the background This is not fast and does not happen right away so generally this can be applied when images are saved.

public static void OptimizePngImage(string pngFilename,     int level)

ReadAllTextAsync

Asynchronously reads files

public static Task ReadAllTextAsync(string filename,     Encoding encoding)

SHFileOperation

public static int SHFileOperation(ref SHFILEOPSTRUCT FileOp)

ShowExternalBrowser

Shows external browser that's been configured in the MM Configuration. Defaults to Chrome

public static void ShowExternalBrowser(string url)

ShowOpenWithDialog

Displays the Windows Open With dialog with options.

public static void ShowOpenWithDialog(string path)

TryConvertToInt32

Safely converts a double to an integer

public static int TryConvertToInt32(double value,     int failValue)

WriteAllTextAsync

Writes out text file content asynchronously

public static Task WriteAllTextAsync(string filename,     string text,     Encoding encoding)

Utf8EncodingWithoutBom

Reusable UTF-8 Encoding that doesn't have a BOM as the .NET default Encoding.Utf8 has.

Requirements

Namespace: MarkdownMonster
Assembly: markdownmonster.exe

© West Wind Technologies, 2016-2024 • Updated: 11/23/21
Comment or report problem with topic