3using System.Collections.Generic;
7using System.Runtime.InteropServices;
10using System.Threading.Tasks;
14#pragma warning disable 1591
16 public class DeleteFiles
21 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
25 [MarshalAs(UnmanagedType.U4)]
30 [MarshalAs(UnmanagedType.Bool)]
31 public bool fAnyOperationsAborted;
32 public IntPtr hNameMappings;
33 public string lpszProgressTitle;
36 [DllImport(
"shell32.dll", CharSet = CharSet.Auto)]
37 static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp);
39 const int FO_DELETE = 3;
40 const int FOF_ALLOWUNDO = 0x40;
41 const int FOF_NOCONFIRMATION = 0x10;
46 m_evtCancel = evtCancel;
49 public bool DeleteDirectory(
string strDir)
51 if (!Directory.Exists(strDir))
54 Stopwatch sw =
new Stopwatch();
55 string[] rgstrFiles = Directory.GetFiles(strDir);
59 for (
int i = 0; i < rgstrFiles.Length; i++)
61 File.Delete(rgstrFiles[i]);
71 if (sw.Elapsed.TotalMilliseconds > 1000)
73 m_log.
Progress = (double)i / (
double)rgstrFiles.Length;
74 m_log.
WriteLine(
"deleting " + i.ToString(
"N0") +
" of " + rgstrFiles.Length.ToString(
"N0") +
"...");
79 rgstrFiles = Directory.GetFiles(strDir);
80 if (rgstrFiles.Length == 0)
81 Directory.Delete(strDir);
87#pragma warning restore 1591
The CancelEvent provides an extension to the manual cancel event that allows for overriding the manua...
bool WaitOne(int nMs=int.MaxValue)
Waits for the signal state to occur.
The Log class provides general output in text form.
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
double Progress
Get/set the progress associated with the Log.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...