OpenKeyWord  Build Tag: jenkins-DoxyGen_EN-107, Build ID: 2015-03-08_20-51-06
 All Classes Namespaces Functions Variables Properties Pages
OKW.OKW_FileHelper Class Reference

Static Public Member Functions

static void DirectoryDelete (string fpsPaFiNa)
 
static bool DirectoryExist (string fpsPaFiNa)
 
static void DirectoryMove (string fpsPaNaSource, string fpsPaNaDestination)
 
static void FileDelete (string fpsPaFiNa)
 
static bool FileExist (string fpsPaFiNa)
 
static void FileMove (string fpsPaFiNaSource, string fpsPaFiNaDestination)
 
static bool IsFolderEmpty (string Folder)
 

Static Private Member Functions

static void CopyDirectoryWithIncludedFiles (string dirCopySource, string dirCopyTarget)
 

Detailed Description

Author
Zoltan Hrabovszki
Date
2013.12.30

Member Function Documentation

static void OKW.OKW_FileHelper.CopyDirectoryWithIncludedFiles ( string  dirCopySource,
string  dirCopyTarget 
)
staticprivate
Author
Zoltan Hrabovszki
Date
2013.12.30
285  {
286  // alle Unterverzeichnisse des aktuellen Verzeichnisses ermitteln
287  string[] subDirectories = System.IO.Directory.GetDirectories(dirCopySource);
288 
289  // Zielpfad erzeugen
290  StringBuilder newTargetPath = new StringBuilder();
291  {
292  newTargetPath.Append(dirCopyTarget);
293  newTargetPath.Append(dirCopySource.Substring(dirCopySource.LastIndexOf(@"\")));
294  }
295 
296  // wenn aktueller Ordner nicht existiert -> ersstellen
297  if (!Directory.Exists(newTargetPath.ToString()))
298  {
299  Directory.CreateDirectory(newTargetPath.ToString());
300  }
301 
302  // Unterverzeichnise durchlaufen und Funktion mit dazu gehörigen Zielpfad erneut aufrufen(Rekursion)
303  foreach (string subDirectory in subDirectories)
304  {
305  string newDirectoryPath = subDirectory;
306 
307  // wenn ''/'' an letzter Stelle dann entfernen
308  if (newDirectoryPath.LastIndexOf(@"\") == (newDirectoryPath.Length - 1))
309  {
310  newDirectoryPath = newDirectoryPath.Substring(0, newDirectoryPath.Length - 1);
311  }
312 
313  // rekursiever Aufruf
314  CopyDirectoryWithIncludedFiles(newDirectoryPath, newTargetPath.ToString());
315  }
316 
317  // alle enthaltenden Dateien des aktuellen Verzeichnisses ermitteln
318  string[] fileNames = Directory.GetFiles(dirCopySource);
319  foreach (string fileSource in fileNames)
320  {
321  // Zielpfad + Dateiname
322  StringBuilder fileTarget = new StringBuilder();
323  {
324  fileTarget.Append(newTargetPath);
325  fileTarget.Append(fileSource.Substring(fileSource.LastIndexOf(@"\")));
326  }
327 
328  // Datei kopieren, wenn schon vorhanden überschreiben
329  File.Copy(fileSource, fileTarget.ToString(), true);
330  }
331  }
static void CopyDirectoryWithIncludedFiles(string dirCopySource, string dirCopyTarget)
Definition: OKW_FileHelper.cs:284
static void OKW.OKW_FileHelper.DirectoryDelete ( string  fpsPaFiNa)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
71  {
72  if (System.IO.Directory.Exists(fpsPaFiNa))
73  {
74  // Use a try block to catch IOExceptions, to
75  // handle the case of the file already being
76  // opened by another process.
77  try
78  {
79  System.IO.Directory.Delete(fpsPaFiNa, true);
80  }
81  catch (System.IO.IOException e)
82  {
83  Console.WriteLine(e.Message);
84  return;
85  }
86  }
87 
88  return;
89  }
static bool OKW.OKW_FileHelper.DirectoryExist ( string  fpsPaFiNa)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
102  {
103  return System.IO.Directory.Exists(fpsPaFiNa);
104  }
static void OKW.OKW_FileHelper.DirectoryMove ( string  fpsPaNaSource,
string  fpsPaNaDestination 
)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
118  {
119  if (System.IO.Directory.Exists(fpsPaNaSource))
120  {
121  // Use a try block to catch IOExceptions, to
122  // handle the case of the file already being
123  // opened by another process.
124  try
125  {
126  // Löschen des Zieleverzeichnissen wenn vorhanden
127  System.IO.Directory.Delete(fpsPaNaDestination, true);
128  System.IO.Directory.Move(fpsPaNaSource, fpsPaNaDestination);
129  }
130  catch (System.IO.IOException e)
131  {
132  Console.WriteLine(e.Message);
133  return;
134  }
135  }
136 
137  return;
138  }
static void OKW.OKW_FileHelper.FileDelete ( string  fpsPaFiNa)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
156  {
157  if (System.IO.File.Exists(fpsPaFiNa))
158  {
159  // Use a try block to catch IOExceptions, to
160  // handle the case of the file already being
161  // opened by another process.
162  try
163  {
164  System.IO.File.Delete(fpsPaFiNa);
165  }
166  catch (System.IO.IOException e)
167  {
168  Console.WriteLine(e.Message);
169  return;
170  }
171  }
172 
173  return;
174  }
static bool OKW.OKW_FileHelper.FileExist ( string  fpsPaFiNa)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
188  {
189  bool lvbReturn = false;
190  Logger.Instance.LogFunctionStartDebug("OKW_FileHelper.FileExist", "fpsPaFiNa", fpsPaFiNa);
191  try
192  {
193  lvbReturn = System.IO.File.Exists(fpsPaFiNa);
194 
195  }
196  catch (SystemException e)
197  {
198  Logger.Instance.LogPrintDebug("Exeption: " + e.Message);
199  }
200  finally
201  {
202  Logger.Instance.LogFunctionEndDebug(lvbReturn.ToString());
203  }
204  return lvbReturn;
205  }
static void OKW.OKW_FileHelper.FileMove ( string  fpsPaFiNaSource,
string  fpsPaFiNaDestination 
)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
219  {
220  if (System.IO.File.Exists(fpsPaFiNaSource))
221  {
222  // Use a try block to catch IOExceptions, to
223  // handle the case of the file already being
224  // opened by another process.
225  try
226  {
227  System.IO.File.Delete(fpsPaFiNaDestination);
228  System.IO.File.Move(fpsPaFiNaSource, fpsPaFiNaDestination);
229  }
230  catch (System.IO.IOException e)
231  {
232  Console.WriteLine(e.Message);
233  return;
234  }
235  }
236  else
237  {
238  // Exception auslösen: Datei di nicht vorhanden is kann nicht verschoben werden.
239  }
240 
241  return;
242  }
static bool OKW.OKW_FileHelper.IsFolderEmpty ( string  Folder)
static
Author
Zoltan Hrabovszki
Date
2013.12.30
254  {
255  try
256  {
257  if (Directory.GetDirectories(Folder).Length == 0)
258  {
259  if (Directory.GetFiles(Folder).Length == 0)
260  {
261  return true;
262  }
263  }
264  }
265  catch (Exception)
266  {
267  return false;
268  }
269 
270  return false;
271  }

The documentation for this class was generated from the following file: