internal static void saveUndoLevel(Classes.Project proj, string undoName) { string path = Directory.CreateDirectory(Global.UndoPath + "\\" + proj.U_ID.ToString()).FullName; if (proj.currentUndoLevel == -1) //Or, unsaved... proj.currentUndoLevel = 0; int level = proj.currentUndoLevel + 1; DirectoryInfo inf = Directory. CreateDirectory(Global.UndoPath + "\\" + proj.U_ID.ToString()); try { for (FileInfo[] files = inf.GetFiles(level.ToString() + "-*.vpf"); files.Length > 0; files = inf.GetFiles(level.ToString() + "-*.vpf")) { File.Delete(files[0].FullName); level++; } } catch { } undoName = RemoveInvalidFileChars(undoName); proj.Save(path + "\\" + (proj.currentUndoLevel++).ToString() + "-" + undoName + ".vpf", true); }