Show / Hide Table of Contents

Class FileUtil

Inheritance
object
FileUtil
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: EasySave_Project.Util
Assembly: .dll
Syntax
public class FileUtil

Methods

| Edit this page View Source

AddJobInFile(string, string, string, JobSaveTypeEnum)

Adds a new job to the JSON file.

Declaration
public static void AddJobInFile(string name, string fileSource, string fileTarget, JobSaveTypeEnum jobSaveTypeEnum)
Parameters
Type Name Description
string name

The name of the job.

string fileSource

The source file path.

string fileTarget

The target file path.

JobSaveTypeEnum jobSaveTypeEnum

The type of the save job.

| Edit this page View Source

AddValueToJobSettingsList(string, string)

Declaration
public static void AddValueToJobSettingsList(string key, string value)
Parameters
Type Name Description
string key
string value
| Edit this page View Source

CalculateTotalSize(string)

Calculates the total size of all files in the specified directory.

Declaration
public static long CalculateTotalSize(string directory)
Parameters
Type Name Description
string directory

The directory to calculate the total size for.

Returns
Type Description
long

The total size in bytes.

| Edit this page View Source

CalculateTransferTime(string, string)

Calcule le temps de transfert entre le fichier source et le fichier cible.

Declaration
public static double CalculateTransferTime(string sourceFile, string targetFile)
Parameters
Type Name Description
string sourceFile

Le chemin complet du fichier source.

string targetFile

Le chemin complet du fichier cible.

Returns
Type Description
double

Le temps de transfert en millisecondes, ou -1 en cas d'erreur.

| Edit this page View Source

CombinePath(string, string)

Combines two paths into a single path.

Declaration
public static string CombinePath(string path1, string path2)
Parameters
Type Name Description
string path1

The first path.

string path2

The second path.

Returns
Type Description
string

The combined path.

| Edit this page View Source

CopyFile(string, string, bool)

Copies a file from the source path to the destination path.

Declaration
public static void CopyFile(string sourceFile, string destinationFile, bool overwrite)
Parameters
Type Name Description
string sourceFile

The path of the file to copy.

string destinationFile

The path where the file will be copied.

bool overwrite

Indicates whether to overwrite the destination file if it exists.

| Edit this page View Source

CreateDirectory(string)

Declaration
public static void CreateDirectory(string path)
Parameters
Type Name Description
string path
| Edit this page View Source

EncryptFile(string, string)

Declaration
public static void EncryptFile(string filePath, string key)
Parameters
Type Name Description
string filePath
string key
| Edit this page View Source

EnsureDirectoryAndFileExist(string)

Ensures that the specified directory and file exist. Creates them if they do not exist.

Declaration
public static void EnsureDirectoryAndFileExist(string fileName)
Parameters
Type Name Description
string fileName

The name of the file to check/create.

| Edit this page View Source

ExistsDirectory(string)

Checks whether a directory exists at the specified path.

Declaration
public static bool ExistsDirectory(string path)
Parameters
Type Name Description
string path

The path to check for the existence of a directory.

Returns
Type Description
bool

True if the directory exists; otherwise, false.

| Edit this page View Source

ExistsFile(string)

Checks whether a file exists at the specified path.

Declaration
public static bool ExistsFile(string path)
Parameters
Type Name Description
string path

The path to check for the existence of a file.

Returns
Type Description
bool

True if the file exists; otherwise, false.

| Edit this page View Source

GetAllFilesAndDirectories(string)

Retrieves all files from a directory, including its subdirectories recursively.

Declaration
public static List<string> GetAllFilesAndDirectories(string rootPath)
Parameters
Type Name Description
string rootPath
Returns
Type Description
List<string>

A list of full file paths found in the directory and its subdirectories.

| Edit this page View Source

GetAppSettingsInt(string)

Retrieves a specified integer value from the AppSettingDto object. If the key is not present or invalid, it returns a default value.

Declaration
public static int GetAppSettingsInt(string key)
Parameters
Type Name Description
string key

The property name of the integer value (e.g., "MaxLargeFileSize").

Returns
Type Description
int

The integer value stored in the specified property, or 0 if not found.

| Edit this page View Source

GetAppSettingsList(string)

Retrieves a specified list from the JobSettingsDto object. If the list is not present or empty, it returns an empty list.

Declaration
public static List<string> GetAppSettingsList(string key)
Parameters
Type Name Description
string key

The property name of the list (e.g., "EncryptedFileExtensions" or "PriorityBusinessProcess").

Returns
Type Description
List<string>

A list of values stored in the specified property.

| Edit this page View Source

GetCurrentJobIndex()

Gets the current job index from the JSON file.

Declaration
public static int GetCurrentJobIndex()
Returns
Type Description
int

The current job index, or 0 if not found.

| Edit this page View Source

GetDirectories(string)

Retrieves all subdirectories in the specified directory.

Declaration
public static IEnumerable<string> GetDirectories(string path)
Parameters
Type Name Description
string path

The path of the directory to retrieve subdirectories from.

Returns
Type Description
IEnumerable<string>

An enumerable collection of directory paths.

| Edit this page View Source

GetDirectoryName(string)

Retrieves the directory name from the specified path.

Declaration
public static string GetDirectoryName(string path)
Parameters
Type Name Description
string path

The path from which to retrieve the directory name.

Returns
Type Description
string

The directory name, or null if the path is invalid.

| Edit this page View Source

GetFileExtension(string)

Retrieves the file extension from the given file path.

Declaration
public static string GetFileExtension(string filePath)
Parameters
Type Name Description
string filePath

The path of the file.

Returns
Type Description
string

The file extension, or an empty string if the file has no extension.

| Edit this page View Source

GetFileName(string)

Retrieves the file name from the specified path.

Declaration
public static string GetFileName(string path)
Parameters
Type Name Description
string path

The path from which to retrieve the file name.

Returns
Type Description
string

The file name, or null if the path is invalid.

| Edit this page View Source

GetFileSize(string)

Obtient la taille d'un fichier en octets.

Declaration
public static long GetFileSize(string filePath)
Parameters
Type Name Description
string filePath

Le chemin complet du fichier.

Returns
Type Description
long

La taille du fichier en octets, ou -1 si le fichier n'existe pas.

| Edit this page View Source

GetFiles(string)

Retrieves all files in the specified directory.

Declaration
public static List<string> GetFiles(string path)
Parameters
Type Name Description
string path

The path of the directory to retrieve files from.

Returns
Type Description
List<string>

An enumerable collection of file paths.

| Edit this page View Source

GetJobIndex()

Gets the current job index from the JSON file and increments it for a new job.

Declaration
public static int GetJobIndex()
Returns
Type Description
int

The incremented job index.

| Edit this page View Source

GetLastWriteTime(string)

Retrieves the last write time of the specified file.

Declaration
public static DateTime GetLastWriteTime(string path)
Parameters
Type Name Description
string path

The path of the file to retrieve the last write time from.

Returns
Type Description
DateTime

The DateTime of the last write time.

| Edit this page View Source

GetRelativePath(string, string)

Gets the relative path of a file or directory based on the provided root directory.

Declaration
public static string GetRelativePath(string rootDir, string fullPath)
Parameters
Type Name Description
string rootDir

The root directory to base the relative path on.

string fullPath

The full path of the file or directory.

Returns
Type Description
string

The relative path from the root directory to the specified file or directory.

| Edit this page View Source

IncrementJobIndex(JobSettingsDto)

Increments the job index in the JSON file.

Declaration
public static void IncrementJobIndex(JobSettingsDto data)
Parameters
Type Name Description
JobSettingsDto data
| Edit this page View Source

RemoveValueFromJobSettingsList(string, string)

Declaration
public static void RemoveValueFromJobSettingsList(string key, string value)
Parameters
Type Name Description
string key
string value
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX