private static void deleteAllAccessFiles() { foreach (var file in Directory.GetFiles(GetInfo.GetAppDataPath() + "Access Files")) { File.Delete(file); } }
//This determines whether access locks currently exist on the launcher's access files. This is an effective way to //determine whether or not any of the files is currently open. private bool accessLocksExist() { var locks = from filePath in Directory.EnumerateFiles(GetInfo.GetAppDataPath() + "Access Files") where filePath.EndsWith(".laccdb") select new FileInfo(filePath); if (locks.Count() > 0) { return(true); } else { return(false); } }
public void Excecute() { //1. instantiate _autoEvent so it can be used later. _autoEvent = new AutoResetEvent(false); //2. Put text on Console for background operation and disable the "x" button. disableConsoleClose(); //3. Initial check for Access locks _accessIsOpen = accessLocksExist(); //4. Watch local access files for locks. While they exist:. FileSystemWatcher watcher = new FileSystemWatcher(GetInfo.GetAppDataPath() + "\\Access Files"); watcher.Deleted += new FileSystemEventHandler(onDeleted); watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Size; //4. Run a timer that will call a specific callback method every 5 minutes. watcher.EnableRaisingEvents = true; TimerCallback tcb = checkForUpdateTimerCallBack; this._timer = new Timer(tcb, null, new TimeSpan(0, 2, 0), new TimeSpan(0, 2, 0)); //5. Wait for an autoevent to be raised to continue execution this._autoEvent.WaitOne(); this._timer.Dispose(); //6. If autoevent is triggered, then... if (_lockout) { lockUserOut(); } else if (_needsUpdate) { updateUser(); } else { watcher.Dispose(); return; } }
private static void extractZipFile(DTO.Enums.UserTypeEnum userType) { ZipFile.ExtractToDirectory(GetDataFromXml.GetLatestRollout(userType, DTO.Enums.BackEndOrFrontEndEnum.FrontEnd).ZipPath, GetInfo.GetAppDataPath() + "\\Access Files\\"); }