WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
DirectoryInfoExtensions.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 
7 namespace System.IO
8 {
12  public static class DirectoryInfoExtensions
13  {
14 
18  public static void CreateDirectoryPath(this DirectoryInfo DI)
19  {
20  if (DI.Exists) return;
21  if (DI.Parent != null)
22  {
23  CreateDirectoryPath(DI.Parent);
24  }
25  if (!DI.Exists)
26  {
27  DI.Create();
28  }
29 
30 
31 
32 
33  }
34 
35 
36  public static DirectoryInfo AppendPath(this DirectoryInfo DI, string PathToAppend)
37  {
38  return new DirectoryInfo(Path.Combine(DI.FullName, PathToAppend));
39  }
40 
41 
42 
43  public static bool CheckExists(this DirectoryInfo DI)
44  {
45  return new DirectoryInfo(DI.FullName).Exists;
46  }
47 
48  public static void DeleteAllDirectories(this DirectoryInfo DI)
49  {
50  foreach (DirectoryInfo D in DI.GetDirectories())
51  {
52  try
53  {
54  DI.Delete(true);
55  }
56  catch
57  {
58 
59  }
60  }
61  }
62 
63 
64  public static void DeleteAllFiles(this DirectoryInfo DI)
65  {
66  foreach (FileInfo FI in DI.GetFiles())
67  {
68  try
69  {
70  FI.Delete();
71  }
72  catch
73  {
74 
75  }
76  }
77  }
78 
79 
80  }
81 }