コード例 #1
0
        public FilesController()
        {
            Context = new FileViewerContext();

            if (!DataBaseCleaned)
            {
                Viewer viewer = new Viewer();
                Task.Run(() => Viewer.CleanDataBase());

                DataBaseCleaned = true;
            }
        }
コード例 #2
0
        public static void CleanDataBase()
        {
            FileViewerContext context   = new FileViewerContext();
            List <PathInfo>   pathInfos = context.PathInfos.ToList();

            foreach (PathInfo pathInfo in pathInfos)
            {
                if (!Directory.Exists(pathInfo.RootPath))
                {
                    context.Entry(pathInfo).State = System.Data.Entity.EntityState.Deleted;
                }
            }

            context.SaveChanges();

            return;
        }