public void writeAllDecks() {
        try {
            //store the files that do exist
            List<File> files = new ArrayList<File>();
            files.addAll(asList(deckDir.listFiles(DCKFileFilter)));

            //save the files and remove them from the list
            for (Deck deck : deckMap.values()) {
                File f = new File(deckDir, deriveFileName(deck.getName()) + ".dck");
                files.remove(f);
                BufferedWriter out = new BufferedWriter(new FileWriter(f));
                writeDeck(deck, out);
                out.close();
            }
            //delete the files that were not written out: the decks that were deleted
            for (File file : files) {
                file.delete();
            }

            //store the files that do exist
            files.clear();
            files.addAll(asList(deckDir.listFiles(BDKFileFilter)));

            //save the files and remove them from the list
            for (Entry<String, Deck[]> e : draftMap.entrySet()) {
                File f = new File(deckDir, deriveFileName(e.getValue()[0].getName()) + ".bdk");
                f.mkdir();
                for (int i = 0; i < e.getValue().length; i++) {
                    BufferedWriter out = new BufferedWriter(new FileWriter(new File(f, i + ".dck")));
                    writeDeck(e.getValue()[i], out);
                    out.close();
                }
            }
            /*
            //delete the files that were not written out: the decks that were deleted
            for(File file:files) {
                for(int i = 0; i < 8; i++)
                    new File(file, i + ".dck").delete();
                file.delete();
            }
            */
        } catch (IOException ex) {
            ErrorViewer.showError(ex);
            throw new RuntimeException("DeckManager : writeDeck() error, " + ex.getMessage());
        }
    }