BogaNet 1.4.0
Loading...
Searching...
No Matches
Static Public Member Functions | Properties | List of all members
BogaNet.Helper.FileHelper Class Referenceabstract

Various helper functions for filesystem operations. More...

Static Public Member Functions

static bool IsUnixPath (string? path)
 Checks if the given path is from a Unix-device.
 
static bool IsWindowsPath (string? path)
 Checks if the given path is from a Windows-device.
 
static bool IsUNCPath (string? path)
 Checks if the given path is UNC.
 
static bool IsURL (string? path)
 Checks if the given path is an URL.
 
static string ValidatePath (string path, bool addEndDelimiter=true, bool preserveFile=true, bool removeInvalidChars=true)
 Validates a given path and add missing slash.
 
static string ValidateFile (string path, bool removeInvalidChars=true)
 Validates a given file.
 
static bool HasPathInvalidChars (string? path, bool ignoreNullOrEmpty=true)
 Checks a given path for invalid characters.
 
static bool HasFileInvalidChars (string? file, bool ignoreNullOrEmpty=true)
 Checks a given file for invalid characters.
 
static string[] GetFilesForName (string path, bool isRecursive=false, params string[]? filenames)
 Find files inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static string[] GetFiles (string path, bool isRecursive=false, params string[]? extensions)
 Find files inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static string[] GetDirectories (string path, bool isRecursive=false)
 Find directories inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static string[] GetDrives ()
 Find all logical drives.
 
static DriveInfo[] GetDriveInfo ()
 Gathers all information for all logical drives.
 
static string Combine (string path1, string path2)
 Combines two paths together.
 
static bool Copy (string sourcePath, string destPath, bool move=false, bool moveSafe=true)
 Copy or move a file or directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool CopyFile (string sourceFile, string destFile, bool move=false, bool moveSafe=true)
 Copy or move a file. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool CopyDirectory (string sourceDir, string destDir, bool move=false, bool moveSafe=true)
 Copy or move a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool Move (string sourcePath, string destPath)
 Move a file or directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool MoveFile (string sourceFile, string destFile)
 Move a file. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool MoveDirectory (string sourceDir, string destDir)
 Move a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static string Rename (string path, string newName)
 Renames a file or directory.
 
static string RenameFile (string path, string newName)
 Renames a file in a path.
 
static string RenameDirectory (string path, string newName)
 Renames a directory in a path.
 
static bool Delete (string path)
 Delete a file or directory.
 
static bool DeleteFile (string file)
 Delete a file.
 
static bool DeleteDirectory (string dir)
 Delete a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.
 
static bool Exists (string path)
 Checks if a file or directory exists.
 
static bool ExistsFile (string path)
 Checks if a file exists.
 
static bool ExistsDirectory (string path)
 Checks if a directory exists.
 
static string CreateFile (string path, string fileName)
 Creates a file in a given path.
 
static string CreateDirectory (string path, string folderName)
 Creates a directory in a given path.
 
static bool CreateFile (string path)
 Creates a file.
 
static bool CreateDirectory (string path)
 Creates a directory.
 
static bool IsDirectory (string? path, bool checkForExtensions=true)
 Checks if the path is a directory.
 
static bool IsFile (string? path, bool checkForExtensions=true)
 Checks if the path is a file.
 
static bool IsRoot (string? path)
 Checks if the path is the root.
 
static string GetName (string path)
 Returns the name for the file or directory.
 
static string GetFileName (string path, bool removeInvalidChars=true)
 Returns the file name for the path.
 
static string GetDirectoryName (string path, bool fullPath=false)
 Returns the directory name for the path.
 
static long GetSize (string path)
 Returns the size of a file or directory in bytes.
 
static long GetFileSize (string path)
 Returns the size of a file in bytes.
 
static long GetDirectorySize (string path)
 Returns the size of a directory in bytes.
 
static string GetExtension (string path)
 Returns the extension of a file.
 
static DateTime GetLastWriteTime (string path)
 Returns the last write (=modified) timestamp of a file or directory.
 
static DateTime GetLastAccessTime (string path)
 Returns the last access (=read) timestamp of a file or directory.
 
static DateTime GetCreationTime (string path)
 Returns the creation timestamp of a file or directory.
 
static DateTime GetLastFileWriteTime (string file)
 Returns the last write (=modified) timestamp of a file.
 
static DateTime GetLastFileAccessTime (string file)
 Returns the last access (=read) timestamp of a file.
 
static DateTime GetFileCreationTime (string file)
 Returns the creation timestamp of a file.
 
static DateTime GetLastDirectoryWriteTime (string path)
 Returns the last write (=modified) timestamp of directory.
 
static DateTime GetLastDirectoryAccessTime (string path)
 Returns the last access (=read) timestamp of a directory.
 
static DateTime GetDirectoryCreationTime (string path)
 Returns the creation timestamp of a directory.
 
static string ReadAllText (string path, Encoding? encoding=null)
 Reads the text of a file.
 
static async Task< string > ReadAllTextAsync (string path, Encoding? encoding=null)
 Reads the text of a file asynchronously.
 
static string[] ReadAllLines (string path, Encoding? encoding=null)
 Reads all lines of text from a file.
 
static async Task< string[]> ReadAllLinesAsync (string path, Encoding? encoding=null)
 Reads all lines of text from a file asynchronously.
 
static byte[] ReadAllBytes (string path)
 Reads the bytes of a file.
 
static async Task< byte[]> ReadAllBytesAsync (string path)
 Reads the bytes of a file asynchronously.
 
static bool WriteAllText (string destFile, string text, Encoding? encoding=null)
 Writes text to a file.
 
static async Task< bool > WriteAllTextAsync (string destFile, string text, Encoding? encoding=null)
 Writes text to a file asynchronously.
 
static bool WriteAllLines (string destFile, string[] lines, Encoding? encoding=null)
 Writes all lines of text to a file.
 
static async Task< bool > WriteAllLinesAsync (string destFile, string[] lines, Encoding? encoding=null)
 Writes all lines of text to a file asynchronously.
 
static bool WriteAllBytes (string destFile, byte[] data)
 Writes bytes to a file.
 
static async Task< bool > WriteAllBytesAsync (string destFile, byte[] data)
 Writes bytes to a file asynchronously.
 
static bool Show (string? path)
 Shows the location of a file or directory in OS file explorer. NOTE: only works on standalone platforms.
 
static bool OpenFile (string? file)
 Opens a file with the OS default application. NOTE: only works for standalone platforms.
 

Properties

static string TempFile [get]
 Returns a temporary file.
 
static string TempPath [get]
 Returns the temporary directory path.
 
static string TempDirectory [get]
 Returns a temporary directory.
 
static string CurrentDirectory [get]
 Returns the current directory.
 

Detailed Description

Various helper functions for filesystem operations.

Member Function Documentation

◆ Combine()

static string BogaNet.Helper.FileHelper.Combine ( string path1,
string path2 )
static

Combines two paths together.

Parameters
path1First path
path2Second path
Returns
Combined path
Exceptions
ArgumentNullException

◆ Copy()

static bool BogaNet.Helper.FileHelper.Copy ( string sourcePath,
string destPath,
bool move = false,
bool moveSafe = true )
static

Copy or move a file or directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourcePathSource file/directory path
destPathDestination file/directory path
moveMove file/directory instead of copy (optional, default: false)
moveSafeMoves a file/directory in a safe, but slower way (optional, default: true)
Returns
True if the operation was successful
Exceptions
Exception

◆ CopyDirectory()

static bool BogaNet.Helper.FileHelper.CopyDirectory ( string sourceDir,
string destDir,
bool move = false,
bool moveSafe = true )
static

Copy or move a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourceDirSource directory path
destDirDestination directory path
moveMove directory instead of copy (optional, default: false)
moveSafeMoves a directory in a safe, but slower way (optional, default: true)
Returns
True if the operation was successful
Exceptions
Exception

◆ CopyFile()

static bool BogaNet.Helper.FileHelper.CopyFile ( string sourceFile,
string destFile,
bool move = false,
bool moveSafe = true )
static

Copy or move a file. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourceFileSource file path
destFileDestination file path
moveMove file instead of copy (optional, default: false)
moveSafeMoves a file in a safe, but slower way (optional, default: true)
Returns
True if the operation was successful
Exceptions
Exception

◆ CreateDirectory() [1/2]

static bool BogaNet.Helper.FileHelper.CreateDirectory ( string path)
static

Creates a directory.

Parameters
pathPath to the directory to create
Returns
True if the operation was successful
Exceptions
Exception

◆ CreateDirectory() [2/2]

static string BogaNet.Helper.FileHelper.CreateDirectory ( string path,
string folderName )
static

Creates a directory in a given path.

Parameters
pathPath for the directory
folderNameNew folder
Exceptions
Exception

◆ CreateFile() [1/2]

static bool BogaNet.Helper.FileHelper.CreateFile ( string path)
static

Creates a file.

Parameters
pathPath to the file to create
Returns
True if the operation was successful
Exceptions
Exception

◆ CreateFile() [2/2]

static string BogaNet.Helper.FileHelper.CreateFile ( string path,
string fileName )
static

Creates a file in a given path.

Parameters
pathPath for the file
fileNameNew file
Exceptions
Exception

◆ Delete()

static bool BogaNet.Helper.FileHelper.Delete ( string path)
static

Delete a file or directory.

Parameters
pathDelete file/directory
Returns
True if the operation was successful
Exceptions
Exception

◆ DeleteDirectory()

static bool BogaNet.Helper.FileHelper.DeleteDirectory ( string dir)
static

Delete a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
dirDirectory to delete
Returns
True if the operation was successful
Exceptions
Exception

◆ DeleteFile()

static bool BogaNet.Helper.FileHelper.DeleteFile ( string file)
static

Delete a file.

Parameters
fileFile to delete
Returns
True if the operation was successful
Exceptions
Exception

◆ Exists()

static bool BogaNet.Helper.FileHelper.Exists ( string path)
static

Checks if a file or directory exists.

Parameters
pathPath to the file or directory
Returns
True if the file or directory exists
Exceptions
ArgumentNullException

◆ ExistsDirectory()

static bool BogaNet.Helper.FileHelper.ExistsDirectory ( string path)
static

Checks if a directory exists.

Parameters
pathPath to the directory
Returns
True if the directory exists

◆ ExistsFile()

static bool BogaNet.Helper.FileHelper.ExistsFile ( string path)
static

Checks if a file exists.

Parameters
pathPath to the file
Returns
True if the file exists

◆ GetCreationTime()

static DateTime BogaNet.Helper.FileHelper.GetCreationTime ( string path)
static

Returns the creation timestamp of a file or directory.

Parameters
pathPath to the file/directory
Returns
Creation timestamp
Exceptions
Exception

◆ GetDirectories()

static string[] BogaNet.Helper.FileHelper.GetDirectories ( string path,
bool isRecursive = false )
static

Find directories inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
pathPath to find the directories
isRecursiveRecursive search (optional, default: false)
Returns
Returns array of the found directories inside the path. Zero length array when an error occured
Exceptions
Exception

◆ GetDirectoryCreationTime()

static DateTime BogaNet.Helper.FileHelper.GetDirectoryCreationTime ( string path)
static

Returns the creation timestamp of a directory.

Parameters
pathPath to the directory
Returns
Creation timestamp
Exceptions
Exception

◆ GetDirectoryName()

static string BogaNet.Helper.FileHelper.GetDirectoryName ( string path,
bool fullPath = false )
static

Returns the directory name for the path.

Parameters
pathPath to the directory
fullPathReturn the full path to the directory (optional, default: false)
Returns
Directory name for the path
Exceptions
Exception

◆ GetDirectorySize()

static long BogaNet.Helper.FileHelper.GetDirectorySize ( string path)
static

Returns the size of a directory in bytes.

Parameters
pathPath of the directory
Returns
Size of the directory
Exceptions
Exception

◆ GetDriveInfo()

static DriveInfo[] BogaNet.Helper.FileHelper.GetDriveInfo ( )
static

Gathers all information for all logical drives.

Returns
Array with DriveInfo

◆ GetDrives()

static string[] BogaNet.Helper.FileHelper.GetDrives ( )
static

Find all logical drives.

Returns
Returns array of the found drives. Zero length array when an error occured
Exceptions
Exception

◆ GetExtension()

static string BogaNet.Helper.FileHelper.GetExtension ( string path)
static

Returns the extension of a file.

Parameters
pathPath to the file
Returns
Extension of the file
Exceptions
Exception

◆ GetFileCreationTime()

static DateTime BogaNet.Helper.FileHelper.GetFileCreationTime ( string file)
static

Returns the creation timestamp of a file.

Parameters
filePath to the file
Returns
Creation timestamp
Exceptions
Exception

◆ GetFileName()

static string BogaNet.Helper.FileHelper.GetFileName ( string path,
bool removeInvalidChars = true )
static

Returns the file name for the path.

Parameters
pathPath to the file
removeInvalidCharsRemoves invalid characters in the file name (optional, default: true)
Returns
File name for the path

◆ GetFiles()

static string[] BogaNet.Helper.FileHelper.GetFiles ( string path,
bool isRecursive = false,
params string?[] extensions )
static

Find files inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
pathPath to find the files
isRecursiveRecursive search (optional, default: false)
extensionsExtensions for the file search, e.g. "png" (optional)
Returns
Returns array of the found files inside the path (alphabetically ordered). Zero length array when an error occured
Exceptions
Exception

◆ GetFilesForName()

static string[] BogaNet.Helper.FileHelper.GetFilesForName ( string path,
bool isRecursive = false,
params string?[] filenames )
static

Find files inside a path. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
pathPath to find the files
isRecursiveRecursive search (optional, default: false)
filenamesArray of file names for the file search, e.g. "Image.png" (optional)
Returns
Returns array of the found files inside the path (alphabetically ordered). Zero length array when an error occured
Exceptions
Exception

◆ GetFileSize()

static long BogaNet.Helper.FileHelper.GetFileSize ( string path)
static

Returns the size of a file in bytes.

Parameters
pathPath of the file
Returns
Size of the file
Exceptions
Exception

◆ GetLastAccessTime()

static DateTime BogaNet.Helper.FileHelper.GetLastAccessTime ( string path)
static

Returns the last access (=read) timestamp of a file or directory.

Parameters
pathPath to the file/directory
Returns
Last access timestamp
Exceptions
Exception

◆ GetLastDirectoryAccessTime()

static DateTime BogaNet.Helper.FileHelper.GetLastDirectoryAccessTime ( string path)
static

Returns the last access (=read) timestamp of a directory.

Parameters
pathPath to the directory
Returns
Last access timestamp
Exceptions
Exception

◆ GetLastDirectoryWriteTime()

static DateTime BogaNet.Helper.FileHelper.GetLastDirectoryWriteTime ( string path)
static

Returns the last write (=modified) timestamp of directory.

Parameters
pathPath to the directory
Returns
Last write timestamp
Exceptions
Exception

◆ GetLastFileAccessTime()

static DateTime BogaNet.Helper.FileHelper.GetLastFileAccessTime ( string file)
static

Returns the last access (=read) timestamp of a file.

Parameters
filePath to the file
Returns
Last access timestamp
Exceptions
Exception

◆ GetLastFileWriteTime()

static DateTime BogaNet.Helper.FileHelper.GetLastFileWriteTime ( string file)
static

Returns the last write (=modified) timestamp of a file.

Parameters
filePath to the file
Returns
Last write timestamp
Exceptions
Exception

◆ GetLastWriteTime()

static DateTime BogaNet.Helper.FileHelper.GetLastWriteTime ( string path)
static

Returns the last write (=modified) timestamp of a file or directory.

Parameters
pathPath to the file/directory
Returns
Last write timestamp
Exceptions
Exception

◆ GetName()

static string BogaNet.Helper.FileHelper.GetName ( string path)
static

Returns the name for the file or directory.

Parameters
pathPath to the file/directory
Returns
File name for file/directory path

◆ GetSize()

static long BogaNet.Helper.FileHelper.GetSize ( string path)
static

Returns the size of a file or directory in bytes.

Parameters
pathPath of the file/directory
Returns
Size of the file/directory
Exceptions
Exception

◆ HasFileInvalidChars()

static bool BogaNet.Helper.FileHelper.HasFileInvalidChars ( string? file,
bool ignoreNullOrEmpty = true )
static

Checks a given file for invalid characters.

Parameters
fileFile to check for invalid characters
ignoreNullOrEmptyIf set to true, return false for null or empty paths (optional, default: true)
Returns
Returns true if the file contains invalid chars, otherwise it's false

◆ HasPathInvalidChars()

static bool BogaNet.Helper.FileHelper.HasPathInvalidChars ( string? path,
bool ignoreNullOrEmpty = true )
static

Checks a given path for invalid characters.

Parameters
pathPath to check for invalid characters
ignoreNullOrEmptyIf set to true, return false for null or empty paths (optional, default: true)
Returns
Returns true if the path contains invalid chars, otherwise it's false

◆ IsDirectory()

static bool BogaNet.Helper.FileHelper.IsDirectory ( string? path,
bool checkForExtensions = true )
static

Checks if the path is a directory.

Parameters
pathPath to the directory
checkForExtensionsCheck for extensions (optional, default: true)
Returns
True if the path is a directory

◆ IsFile()

static bool BogaNet.Helper.FileHelper.IsFile ( string? path,
bool checkForExtensions = true )
static

Checks if the path is a file.

Parameters
pathPath to the file
checkForExtensionsCheck for extensions (optional, default: true)
Returns
True if the path is a file

◆ IsRoot()

static bool BogaNet.Helper.FileHelper.IsRoot ( string? path)
static

Checks if the path is the root.

Parameters
pathPossible root
Returns
True if the path is the root

◆ IsUNCPath()

static bool BogaNet.Helper.FileHelper.IsUNCPath ( string? path)
static

Checks if the given path is UNC.

Parameters
pathPath to check
Returns
True if the given path is UNC

◆ IsUnixPath()

static bool BogaNet.Helper.FileHelper.IsUnixPath ( string? path)
static

Checks if the given path is from a Unix-device.

Parameters
pathPath to check
Returns
True if the given path is from a Unix-device

◆ IsURL()

static bool BogaNet.Helper.FileHelper.IsURL ( string? path)
static

Checks if the given path is an URL.

Parameters
pathPath to check
Returns
True if the given path is an URL

◆ IsWindowsPath()

static bool BogaNet.Helper.FileHelper.IsWindowsPath ( string? path)
static

Checks if the given path is from a Windows-device.

Parameters
pathPath to check
Returns
True if the given path is from a Windows-device

◆ Move()

static bool BogaNet.Helper.FileHelper.Move ( string sourcePath,
string destPath )
static

Move a file or directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourcePathSource file/directory path
destPathDestination file/directory path
Returns
True if the operation was successful
Exceptions
Exception

◆ MoveDirectory()

static bool BogaNet.Helper.FileHelper.MoveDirectory ( string sourceDir,
string destDir )
static

Move a directory. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourceDirSource directory path
destDirDestination directory path
Returns
True if the operation was successful
Exceptions
Exception

◆ MoveFile()

static bool BogaNet.Helper.FileHelper.MoveFile ( string sourceFile,
string destFile )
static

Move a file. NOTE: for a non-blocking version, consider calling this method from a separate thread.

Parameters
sourceFileSource file path
destFileDestination file path
Returns
True if the operation was successful
Exceptions
Exception

◆ OpenFile()

static bool BogaNet.Helper.FileHelper.OpenFile ( string? file)
static

Opens a file with the OS default application. NOTE: only works for standalone platforms.

Parameters
fileFile path
Returns
True if the operation was successful
Exceptions
Exception

◆ ReadAllBytes()

static byte[] BogaNet.Helper.FileHelper.ReadAllBytes ( string path)
static

Reads the bytes of a file.

Parameters
pathPath to the file
Returns
Byte-content of the file
Exceptions
Exception

◆ ReadAllBytesAsync()

static async Task< byte[]> BogaNet.Helper.FileHelper.ReadAllBytesAsync ( string path)
static

Reads the bytes of a file asynchronously.

Parameters
pathPath to the file
Returns
Byte-content of the file
Exceptions
Exception

◆ ReadAllLines()

static string[] BogaNet.Helper.FileHelper.ReadAllLines ( string path,
Encoding? encoding = null )
static

Reads all lines of text from a file.

Parameters
pathPath to the file
encodingEncoding of the text (optional, default: UTF8)
Returns
Array of text lines from the file
Exceptions
Exception

◆ ReadAllLinesAsync()

static async Task< string[]> BogaNet.Helper.FileHelper.ReadAllLinesAsync ( string path,
Encoding? encoding = null )
static

Reads all lines of text from a file asynchronously.

Parameters
pathPath to the file
encodingEncoding of the text (optional, default: UTF8)
Returns
Array of text lines from the file
Exceptions
Exception

◆ ReadAllText()

static string BogaNet.Helper.FileHelper.ReadAllText ( string path,
Encoding? encoding = null )
static

Reads the text of a file.

Parameters
pathPath to the file
encodingEncoding of the text (optional, default: UTF8)
Returns
Text-content of the file
Exceptions
Exception

◆ ReadAllTextAsync()

static async Task< string > BogaNet.Helper.FileHelper.ReadAllTextAsync ( string path,
Encoding? encoding = null )
static

Reads the text of a file asynchronously.

Parameters
pathPath to the file
encodingEncoding of the text (optional, default: UTF8)
Returns
Text-content of the file
Exceptions
Exception

◆ Rename()

static string BogaNet.Helper.FileHelper.Rename ( string path,
string newName )
static

Renames a file or directory.

Parameters
pathPath to the file/directory
newNameNew name for the file/directory
Returns
New path of the file/directory
Exceptions
Exception

◆ RenameDirectory()

static string BogaNet.Helper.FileHelper.RenameDirectory ( string path,
string newName )
static

Renames a directory in a path.

Parameters
pathPath to the directory
newNameNew name for the directory
Returns
New path of the directory
Exceptions
Exception

◆ RenameFile()

static string BogaNet.Helper.FileHelper.RenameFile ( string path,
string newName )
static

Renames a file in a path.

Parameters
pathPath to the file
newNameNew name for the file
Returns
New path of the file
Exceptions
Exception

◆ Show()

static bool BogaNet.Helper.FileHelper.Show ( string? path)
static

Shows the location of a file or directory in OS file explorer. NOTE: only works on standalone platforms.

Parameters
pathPath to the file/directory
Returns
True if the operation was successful
Exceptions
Exception

◆ ValidateFile()

static string BogaNet.Helper.FileHelper.ValidateFile ( string path,
bool removeInvalidChars = true )
static

Validates a given file.

Parameters
pathFile to validate
removeInvalidCharsRemoves invalid characters in the file name (optional, default: true)
Returns
Valid file path
Exceptions
ArgumentNullException

◆ ValidatePath()

static string BogaNet.Helper.FileHelper.ValidatePath ( string path,
bool addEndDelimiter = true,
bool preserveFile = true,
bool removeInvalidChars = true )
static

Validates a given path and add missing slash.

Parameters
pathPath to validate
addEndDelimiterAdd delimiter at the end of the path (optional, default: true)
preserveFilePreserves a given file in the path (optional, default: true)
removeInvalidCharsRemoves invalid characters in the path name (optional default: true)
Returns
Valid path (if possible)
Exceptions
ArgumentNullException

◆ WriteAllBytes()

static bool BogaNet.Helper.FileHelper.WriteAllBytes ( string destFile,
byte[] data )
static

Writes bytes to a file.

Parameters
destFileDestination file path
dataByte-content to write
Returns
True if the operation was successful
Exceptions
Exception

◆ WriteAllBytesAsync()

static async Task< bool > BogaNet.Helper.FileHelper.WriteAllBytesAsync ( string destFile,
byte[] data )
static

Writes bytes to a file asynchronously.

Parameters
destFileDestination file path
dataByte-content to write
Returns
True if the operation was successful
Exceptions
Exception

◆ WriteAllLines()

static bool BogaNet.Helper.FileHelper.WriteAllLines ( string destFile,
string[] lines,
Encoding? encoding = null )
static

Writes all lines of text to a file.

Parameters
destFileDestination file path
linesArray of text lines to write
encodingEncoding of the text (optional, default: UTF8)
Returns
True if the operation was successful
Exceptions
Exception

◆ WriteAllLinesAsync()

static async Task< bool > BogaNet.Helper.FileHelper.WriteAllLinesAsync ( string destFile,
string[] lines,
Encoding? encoding = null )
static

Writes all lines of text to a file asynchronously.

Parameters
destFileDestination file path
linesArray of text lines to write
encodingEncoding of the text (optional, default: UTF8)
Returns
True if the operation was successful
Exceptions
Exception

◆ WriteAllText()

static bool BogaNet.Helper.FileHelper.WriteAllText ( string destFile,
string text,
Encoding? encoding = null )
static

Writes text to a file.

Parameters
destFileDestination file path
textText-content to write
encodingEncoding of the text (optional, default: UTF8)
Returns
True if the operation was successful
Exceptions
Exception

◆ WriteAllTextAsync()

static async Task< bool > BogaNet.Helper.FileHelper.WriteAllTextAsync ( string destFile,
string text,
Encoding? encoding = null )
static

Writes text to a file asynchronously.

Parameters
destFileDestination file path
textText-content to write
encodingEncoding of the text (optional, default: UTF8)
Returns
True if the operation was successful
Exceptions
Exception

Property Documentation

◆ CurrentDirectory

string BogaNet.Helper.FileHelper.CurrentDirectory
staticget

Returns the current directory.

Returns
Current directory

◆ TempDirectory

string BogaNet.Helper.FileHelper.TempDirectory
staticget

Returns a temporary directory.

Returns
Temporary directory

◆ TempFile

string BogaNet.Helper.FileHelper.TempFile
staticget

Returns a temporary file.

Returns
Temporary file

◆ TempPath

string BogaNet.Helper.FileHelper.TempPath
staticget

Returns the temporary directory path.

Returns
Temporary directory path

The documentation for this class was generated from the following file: