Beispiel #1
0
        private static void RemoveByKey(string key, string searchPath)
        {
            var folderPaths = Directory.GetDirectories(searchPath, "*_" + key, SearchOption.AllDirectories);
            foreach (var folderPath in folderPaths)
            {
                var path = Path.Combine(folderPath, "..\\");
                if (!Directory.Exists(path))
                    continue;
                // Trace.WriteLine("deleting " + path);
                try
                {
                    Directory.Delete(path, true);
                }
                catch (Exception e)
                {
                    Trace.WriteLine("error: " + e.Message);
                }
            }
            // find any left over files by key and delete them
            var assNames = GetByKey(key, searchPath);
            var t = new TaskList();
            var gac = new GacUtility();
            foreach (var s in assNames)
            {
                string a = s;
                t.AddTask(() => gac.Remove(a));
            }
            t.WaitForAll();

        }