SkillAgentSearch skills...

Xabe.FileLock

No description available

Install / Use

/learn @tomaszzmuda/Xabe.FileLock
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Xabe.FileLock

Build Status NuGet version GitHub issues GitHub stars GitHub license HitCount

.NET Standard library providing exclusive lock on file.

Using

Install the Xabe.FileLock NuGet package via nuget:

PM> Install-Package Xabe.FileLock

Creating file lock:

ILock fileLock = new FileLock(file);
fileLock.TryAcquire(TimeSpan.FromSeconds(15), true);

This will create lock file with extension ".lock" in the same directory. Example: "/tmp/data.txt" -> "/tmp/data.lock".

Last parameter is optional and defines if lock should be automatically refreshing before expired.

If file already has lock file, and it time haven't expired, method returns false.

Recommended using

ILock fileLock = new FileLock(file);
if(await fileLock.TryAcquire(TimeSpan.FromSeconds(15), true))
{
	using(fileLock)
	{
		// file operations here
	}
}

Lincence

Xabe.FileLock is licensed under MIT - see License for details.

Related Skills

View on GitHub
GitHub Stars21
CategoryDevelopment
Updated9mo ago
Forks5

Languages

C#

Security Score

77/100

Audited on Jul 4, 2025

No findings