MiJennerFileUtils 0.9.2

dotnet add package MiJennerFileUtils --version 0.9.2
                    
NuGet\Install-Package MiJennerFileUtils -Version 0.9.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiJennerFileUtils" Version="0.9.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiJennerFileUtils" Version="0.9.2" />
                    
Directory.Packages.props
<PackageReference Include="MiJennerFileUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MiJennerFileUtils --version 0.9.2
                    
#r "nuget: MiJennerFileUtils, 0.9.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MiJennerFileUtils@0.9.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MiJennerFileUtils&version=0.9.2
                    
Install as a Cake Addin
#tool nuget:?package=MiJennerFileUtils&version=0.9.2
                    
Install as a Cake Tool

MiJenner.FileUtils

FileUtils is a cross-platform C# .NET class library offering static methods for easy handling of files.

  • FolderExists(string) Method takes a string with folder name and determines if it already exists or not.

  • FileExists(string) Method takes a string with file name and determines if it already exists or not.

  • HasWriteAccess(string, [int]]). Method determines if application has write access to folder (string). This is done by trying to write file with randomly generated file name to the folder.

  • TryCreateFolder(string). Method tries to create given folder. If success returns true else false.

  • TryCreateFile(string). Method tries to create file given by input string. If success returns true, else false.

  • TryCreateFileForce(string). Method works like above, except if file already exists, in which case it is overwritten (cleared).

  • TryDeleteFile(string). Method tries to delete file given by input string. Returns true if deleted or if file did not exist, else false.

  • TryCopyFile(string, string, [bool]). Method tries to copy a file from source to destination. Optional overwrite parameter (default false). Returns true if success, else false.

  • TryMoveFile(string, string, [bool]). Method tries to move a file from source to destination. Optional overwrite parameter (default false). Returns true if success, else false.

Method signatures

public static bool FolderExists(string? folderPath)

public static bool FileExists(string? filePath) 

public static bool HasWriteAccess(string? folderPath, int maxAttempts = 3)

public static bool TryCreateFolder(string? folderPath)

public static bool TryCreateFile(string? filePath)

public static bool TryCreateFileForce(string? filePath)

public static bool TryDeleteFile(string? filePath) 

public static bool TryCopyFile(string? sourcePath, string? destinationPath, bool overwrite = false) 

public static bool TryMoveFile(string? sourcePath, string? destinationPath, bool overwrite = false)

Example

using MiJenner.FileUtils;

string currentDir = Directory.GetCurrentDirectory();
Console.WriteLine("string currentDir = DirectoryGetCurrentDirectory(): " + currentDir);
Console.WriteLine("FileUtils.FolderExists(currentDir): " +FileUtils.FolderExists(currentDir));
Console.WriteLine("FileUtils.FolderExists(\"numb\"): " +FileUtils.FolderExists("blahh"));
Console.WriteLine("FileUtils.HasWriteAccess(currentDir): "+ FileUtils.HasWriteAccess(currentDir));
Console.WriteLine("FileUtils.HasWriteAccess(\"blah\"): " +FileUtils.HasWriteAccess("blahh"));
// pre-cleanup 
File.Delete(Path.Combine(currentDir, "MyFile.txt"));
Console.WriteLine("FileUtils.TryCreateFile(Path.Combine(currentDir, \"MyFile.txt\")): " + FileUtils.TryCreateFile(Path.Combine(currentDir, "MyFile.txt")));
Console.WriteLine("FileUtils.TryCreateFile(Path.Combine(currentDir, \"MyFile-exists.txt\")): " + FileUtils.TryCreateFile(Path.Combine(currentDir, "MyFile-exists.txt")));
string folderPath = Path.Combine(currentDir, "Data");
// pre-cleanup 
try
{
    Directory.Delete(folderPath);
}
catch (Exception)
{
    Console.WriteLine("Folder" + folderPath + "\nWasn't present before trying to create it!");
}
Console.WriteLine("FileUtils.TryCreateFolder(folderPath): "+ FileUtils.TryCreateFolder(folderPath));
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MiJennerFileUtils:

Package Downloads
MiJenner.ConfigUtils-FolderManager

Package Description

MiJennerConfigUtilsFolderManager

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.2 115 3/22/2026
0.9.1 145 3/22/2026
0.9.0 289 9/9/2023 0.9.0 is deprecated because it is no longer maintained.