Exemple #1
0
        private void EnumerateVolumeMountPoints(String volume)
        {
            StringBuilder nameBuffer = new StringBuilder(NativeMethods.MAX_PATH);

            using (SafeFindVolumeMountPointHandle hFind = NativeMethods.FindFirstVolumeMountPoint(volume, nameBuffer, nameBuffer.Capacity))
            {
                if (hFind.IsInvalid)
                {
                    return;
                }

                do
                {
                    string volumeName     = string.Empty;
                    string mountPointName = Path.Combine(volume, nameBuffer.ToString());

                    if (NativeMethods.GetVolumeNameForVolumeMountPoint(mountPointName, nameBuffer, nameBuffer.Capacity))
                    {
                        volumeName = nameBuffer.ToString();
                    }

                    WriteObject(new LinkReparsePointInfo(ReparsePointType.MountPoint, mountPointName, volumeName));
                }while (NativeMethods.FindNextVolumeMountPoint(hFind, nameBuffer, nameBuffer.Capacity));
            }
        }
 internal extern static bool FindNextVolumeMountPoint(SafeFindVolumeMountPointHandle hFindVolume, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
Exemple #3
0
 public static extern bool FindNextVolumeMountPoint(
     SafeFindVolumeMountPointHandle hFindVolume,
     StringBuilder lpszVolumeMountPointName,
     int cchStringBufferLength);