public void Enumeration() { new Utilities.IO.DirectoryInfo("~/Logs/").Delete(); new Utilities.IO.DirectoryInfo("~/App_Data/").Delete(); var Temp = new Utilities.IO.DirectoryInfo("."); foreach (IFile File in Temp) { } Assert.Equal(1, Temp.EnumerateDirectories().Count()); Assert.Equal(37, Temp.EnumerateFiles().Count()); Assert.Equal(1, Temp.EnumerateDirectories(x => x.Created < DateTime.UtcNow).Count()); Assert.Equal(37, Temp.EnumerateFiles(x => x.Created < DateTime.UtcNow).Count()); }
public void DeleteExtension() { var Temp = new Utilities.IO.DirectoryInfo("./Test"); Temp.Create(); for (int x = 0; x < 10; ++x) { new Utilities.IO.DirectoryInfo("./Test/" + x).Create(); } Temp.EnumerateDirectories().Delete(); Temp.Delete(); }
/// <summary> /// Auto creates the bundles for the given directory /// </summary> /// <param name="Directory">Directory to create bundles from</param> private void CreateBundles(DirectoryInfo Directory) { if (Directory == null || !Directory.Exists || string.IsNullOrEmpty(Directory.FullName)) return; var BundleDirectory = Directory.FullName.Replace(new DirectoryInfo("~/").FullName, "~/").Replace("\\", "/"); var Bundle = new StyleBundle(BundleDirectory + "/bundle/css"); Bundle.Transforms.Clear(); Bundle.Transforms.Add(new Transformer(this)); if (Directory.Exists) { foreach (string Value in FileTypes[AssetType.CSS]) { Bundle.IncludeDirectory(BundleDirectory, "*." + Value, true); } } var Bundle2 = new ScriptBundle(BundleDirectory + "/bundle/js"); Bundle2.Transforms.Clear(); Bundle2.Transforms.Add(new Transformer(this)); if (Directory.Exists) { foreach (string Value in FileTypes[AssetType.Javascript]) { Bundle2.IncludeDirectory(BundleDirectory, "*." + Value, true); } } BundleTable.Bundles.Add(Bundle); BundleTable.Bundles.Add(Bundle2); foreach (DirectoryInfo SubDirectory in Directory.EnumerateDirectories("*", System.IO.SearchOption.TopDirectoryOnly)) { CreateBundles(SubDirectory); } }
/// <summary> /// Returns an enumerable collection of directory information in the current directory. /// </summary> /// <returns> An enumerable collection of directories in the current directory. </returns> /// <exception cref="T:System.IO.DirectoryNotFoundException">The path encapsulated in the /// <see cref="T:Utilities.IO.DirectoryInfoWrapper" /> /// object is invalid (for example, it is on an unmapped drive).</exception> /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception> public IEnumerable <IDirectoryInfo> EnumerateDirectories() { return(_di.EnumerateDirectories().Select(d => new DirectoryInfoWrapper(d)).ToArray()); }