System.IO.Directory.EnumerateFiles C# (CSharp) Method

EnumerateFiles() public static method

public static EnumerateFiles ( string path ) : System.Collections.Generic.IEnumerable
path string
return System.Collections.Generic.IEnumerable
        public static System.Collections.Generic.IEnumerable<string> EnumerateFiles(string path) { throw null; }
        public static System.Collections.Generic.IEnumerable<string> EnumerateFiles(string path, string searchPattern) { throw null; }

Same methods

Directory::EnumerateFiles ( string path, string searchPattern ) : System.Collections.Generic.IEnumerable
Directory::EnumerateFiles ( string path, string searchPattern, System searchOption ) : System.Collections.Generic.IEnumerable

Usage Example

Esempio n. 1
0
        /// <summary>
        /// The process for backing up a directory index is simple:
        /// a) create hard links to all the files in the lucene directory in a temp director
        ///	   that gives us the current snapshot, and protect us from lucene's
        ///    deleting files.
        /// b) copy the hard links to the destination directory
        /// c) delete the temp directory
        /// </summary>
        public void Execute()
        {
            foreach (var file in Directory.EnumerateFiles(tempPath))
            {
                Notify("Copying " + Path.GetFileName(file));
                var fullName = new FileInfo(file).FullName;
                FileCopy(file, Path.Combine(destination, Path.GetFileName(file)), fileToSize[fullName]);
                Notify("Copied " + Path.GetFileName(file));
            }

            try
            {
                IOExtensions.DeleteDirectory(tempPath);
            }
            catch (Exception e) //cannot delete, probably because there is a file being written there
            {
                logger.WarnFormat(e, "Could not delete {0}, will delete those on startup", tempPath);

                foreach (var file in Directory.EnumerateFiles(tempPath))
                {
                    MoveFileEx(file, null, MoveFileDelayUntilReboot);
                }
                MoveFileEx(tempPath, null, MoveFileDelayUntilReboot);
            }
        }
All Usage Examples Of System.IO.Directory::EnumerateFiles