コード例 #1
0
 private static void CallCallback(DeletePathDelegate callback, string path, bool isFile, bool success)
 {
     if (callback != null)
     {
         callback(path, isFile, success, success ? "" : GetLastErrorString());
     }
 }
コード例 #2
0
 public static void DeletePath(string path, bool force, DeletePathDelegate callback)
 {
     if (File.Exists(path))
     {
         bool success = File.Delete(path, force);
         CallCallback(callback, path, true, success);
     }
     else
     {
         DeletePathRecurse(path, force, callback);
         CallCallback(callback, path, false, Directory.Remove(path, force));
     }
 }
コード例 #3
0
        private static void DeletePathRecurse(string directory, bool force, DeletePathDelegate callback)
        {
            foreach (string file in Directory.GetFiles(directory))
            {
                CallCallback(callback, file, true, File.Delete(file, force));
            }

            foreach (string subdir in Directory.GetDirectories(directory))
            {
                System.IO.Directory.Delete(subdir, true);
                CallCallback(callback, subdir, false, true);
            }
        }
コード例 #4
0
        private static void DeletePathRecurse( string directory, bool force, DeletePathDelegate callback )
        {
            foreach ( string file in Directory.GetFiles( directory ) )
            {
                CallCallback( callback, file, true, File.Delete( file, force ) );
            }

            foreach ( string subdir in Directory.GetDirectories( directory ) )
            {
                System.IO.Directory.Delete( subdir, true );
                CallCallback( callback, subdir, false, true );
            }
        }
コード例 #5
0
 private static void CallCallback( DeletePathDelegate callback, string path, bool isFile, bool success )
 {
     if ( callback != null )
         callback( path, isFile, success, success ? "" : GetLastErrorString() );
 }
コード例 #6
0
 public static void DeletePath( string path, bool force, DeletePathDelegate callback )
 {
     if ( File.Exists( path ) )
     {
         bool success = File.Delete( path, force );
         CallCallback( callback, path, true, success );
     }
     else
     {
         DeletePathRecurse( path, force, callback );
         CallCallback( callback, path, false, Directory.Remove( path, force ) );
     }
 }