Beispiel #1
0
        public FilePath GetFilePathForFileInDirectory(string fileName, bool createDirectory, bool fileShouldExist)
        {
            if (!TryGetFilePathForFileInDirectory(fileName, createDirectory, fileShouldExist, out FilePath filePath))
            {
                throw InvalidFilePathException.WorkingDirectoryFilePathInvalid(fileName);
            }

            return(filePath);
        }
        public static bool IsFilePathOnLockedVolume(string filePath, out Exception ex)
        {
            ex = null;
            List <string> lockedVolumes = BitlockerLockUtil.GetLockedVolumes(out ex);

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

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

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