public FolderLock(string folderPath)
{
try
{
//Lock desktop.ini file....
Logger.Info("Creating folder lock file: " + folderPath);
lockFilePath = Path.Combine(folderPath, FILENAME);
if (!File.Exists(lockFilePath))
{
File.WriteAllLines(lockFilePath, new string[0]);
}
File.SetAttributes(lockFilePath, File.GetAttributes(lockFilePath) | FileAttributes.Hidden | FileAttributes.System);
lockFile = File.Open(lockFilePath, FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (Exception e)
{
Logger.Error("Could not create folder lock: " + lockFilePath, e);
}
}