Пример #1
0
 /// <param name="newAllocation">True if a new handle has been allocated for the caller, the caller must release the handle eventually</param>
 public static SafeFileHandle ObtainHandle(Guid volumeGuid, FileAccess access, ShareMode shareMode, out bool newAllocation)
 {
     if (m_handlePool.ContainsKey(volumeGuid))
     {
         newAllocation = false;
         return(m_handlePool[volumeGuid]);
     }
     else
     {
         newAllocation = true;
         SafeFileHandle handle = HandleUtils.GetVolumeHandle(volumeGuid, access, shareMode);
         m_handlePool.Add(volumeGuid, handle);
         return(handle);
     }
 }
Пример #2
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(string path)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(path, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }
Пример #3
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(Guid volumeGuid)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(volumeGuid, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }
Пример #4
0
        /// <summary>
        /// Note: The NTFS file system treats a locked volume as a dismounted volume.
        /// </summary>
        public static bool IsVolumeMounted(char driveLetter)
        {
            SafeFileHandle handle = HandleUtils.GetVolumeHandle(driveLetter, FileAccess.Read, ShareMode.ReadWrite);

            return(IsVolumeMounted(handle));
        }