예제 #1
0
        /// <summary>
        /// Checks if the lock file exists, and does whatever you ask in the argument.
        /// </summary>
        /// <param name="LockOperation">The operation to perform.</param>
        /// <returns>true if the lock file exists, false otherwise.</returns>
        /// <exception cref="IOException">thrown if the lock file could not be deleted/created</exception>
        public bool IsLocked(LockOperations LockOperation) {
            if (File.Exists(this.LockFileFullPath)) {
                if (LockOperation == LockOperations.RemoveLock)
	                try {	        
                        File.Delete(this.LockFileFullPath);
                    } catch (Exception ex) {
		                throw new IOException("Lock File could not be deleted. Try deleting it manually: " + this.LockFileFullPath ,ex);
	                }
                return true;
            } else {    // Lock file doesn't exist
                if (LockOperation == LockOperations.CreateLock) {
                    try {
                        using (StreamWriter writer = File.CreateText( this.LockFileFullPath )){
                            writer.Write(DateTime.Now.ToString() + " " + Environment.UserName);
                        }
                    } catch (Exception ex) {
                        throw new IOException("Lock File could not be created.",ex);
                    }
                }
                return false;
            }
        }
예제 #2
0
 internal static extern int FLock(IntPtr fd, LockOperations operation);
예제 #3
0
 internal static extern int FLock(SafeFileHandle fd, LockOperations operation);
예제 #4
0
 internal static extern int FLock(IntPtr fd, LockOperations operation);
예제 #5
0
 internal static extern int FLock(SafeFileHandle fd, LockOperations operation);
예제 #6
0
 internal static extern int flock(int fd, LockOperations operation);
예제 #7
0
 internal static partial int FLock(IntPtr fd, LockOperations operation);
예제 #8
0
 internal static partial int FLock(SafeFileHandle fd, LockOperations operation);
예제 #9
0
 internal static extern int FLock(int fd, LockOperations operation);