static public void Unblock(this DirectoryInfo directoryInfo, Boolean recursive)
        {
            if (directoryInfo.Exists == false)
            {
                throw new DirectoryNotFoundException("The specified directory '" + directoryInfo.FullName + "' could not be found.");
            }

            if (directoryInfo.AlternateDataStreamExists(DirectoryInfoExtensions.ZoneIdentifierStreamName))
            {
                directoryInfo.DeleteAlternateDataStream(DirectoryInfoExtensions.ZoneIdentifierStreamName);
            }

            if (recursive)
            {
                foreach (DirectoryInfo subDirectory in directoryInfo.GetDirectories())
                {
                    subDirectory.Unblock(true);
                }

                foreach (FileInfo file in directoryInfo.GetFiles())
                {
                    file.Unblock();
                }
            }
        }
Esempio n. 2
0
        public static void Unblock(this DirectoryInfo directory, bool isRecursive)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(Exceptions.FileIsNull);
            }

            if (!directory.Exists)
            {
                throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "The specified directory '{0}' cannot be found.", directory.FullName));
            }

            if (directory.AlternateDataStreamExists(ZoneIdentifierStreamName))
            {
                directory.DeleteAlternateDataStream(ZoneIdentifierStreamName);
            }

            if (!isRecursive)
            {
                return;
            }

            foreach (DirectoryInfo item in directory.GetDirectories())
            {
                item.Unblock(true);
            }

            foreach (FileInfo item in directory.GetFiles())
            {
                item.Unblock();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Unblocks the directory.
        /// </summary>
        /// <param name="directory">Extension instance.</param>
        /// <param name="recursive">True to recursively unblock all files and folders within the directory.</param>
        static public void Unblock(this DirectoryInfo directory, bool recursive)
        {
            if (directory.Exists == false)
            {
                throw new DirectoryNotFoundException(String.Format(CultureInfo.InvariantCulture, "The specified directory '{0}' could not be found.", directory.FullName));
            }

            if (directory.AlternateDataStreamExists(DirectoryInfoExtensions.ZoneIdentifierStreamName))
            {
                directory.DeleteAlternateDataStream(DirectoryInfoExtensions.ZoneIdentifierStreamName);
            }

            foreach (FileInfo file in directory.GetFiles())
            {
                file.Unblock();
            }

            if (recursive)
            {
                foreach (DirectoryInfo subDirectory in directory.GetDirectories())
                {
                    subDirectory.Unblock(true);
                }
            }
        }