Example #1
0
        public static bool IsFilePathOnEncryptingVolume(string filePath, out Exception ex)
        {
            ex = null;
            List <string> encryptingVolumes = BitlockerUtil.GetEncryptingVolumes(out ex);

            if (ex != null)
            {
                throw new EncryptingVolumesFindException(ex.Message, ex);
            }
            if (encryptingVolumes == null || encryptingVolumes.Count == 0)
            {
                return(false);
            }
            Dictionary <string, string> mountPointVolumeIDMappings = BitlockerUtil.GetMountPointVolumeIDMappings(out ex);

            if (mountPointVolumeIDMappings == null)
            {
                throw new MountPointsFindException(ex.Message, ex);
            }
            bool flag = false;

            foreach (string text in mountPointVolumeIDMappings.Keys)
            {
                if (filePath.StartsWith(text))
                {
                    flag = true;
                    if (encryptingVolumes.Contains(mountPointVolumeIDMappings[text]))
                    {
                        return(true);
                    }
                }
            }
            if (flag)
            {
                return(false);
            }
            throw new InvalidFilePathException(filePath);
        }