MiJenner.FileUtils
0.9.0
dotnet add package MiJenner.FileUtils --version 0.9.0
NuGet\Install-Package MiJenner.FileUtils -Version 0.9.0
<PackageReference Include="MiJenner.FileUtils" Version="0.9.0" />
<PackageVersion Include="MiJenner.FileUtils" Version="0.9.0" />
<PackageReference Include="MiJenner.FileUtils" />
paket add MiJenner.FileUtils --version 0.9.0
#r "nuget: MiJenner.FileUtils, 0.9.0"
#:package MiJenner.FileUtils@0.9.0
#addin nuget:?package=MiJenner.FileUtils&version=0.9.0
#tool nuget:?package=MiJenner.FileUtils&version=0.9.0
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.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).
Method signatures
public static bool FolderExists(string folderPath)
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)
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.Combin(currentDir, \"MyFile.txt\")): " + FileUtils.TryCreateFil(Path.Combine(currentDir, "MyFile.txt")));
Console.WriteLine("FileUtils.TryCreateFile(Path.Combin(currentDir, \"MyFile-exists.txt\")): " + FileUtilsTryCreateFile(Path.Combine(currentDir, "MyFile-existstxt")));
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MiJenner.FileUtils:
Package | Downloads |
---|---|
MiJenner.ConfigUtils-FolderManager
Desktop folder manager - a cross-platform C# class library with functionality to easily determine and create folders for user data and user configurations - and platform detection. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.9.0 | 215 | 9/9/2023 |