Пример #1
0
        private void RefreshData()
        {
            locals.Clear();
            UpdateControl.GetLocalFilesInfo(locals, new System.IO.DirectoryInfo(Application.StartupPath));

            servers = UpdateControl.GetServerFilesInfo();
            if (servers == null)
            {
                servers = new Updates();
            }
            gr = new Updates.grdRecord[locals.Count];
            for (int i = 0; i < locals.Count; i++)
            {
                gr[i] = new Updates.grdRecord(locals[i].FileName, locals[i].ModifyDate.ToString(), "", locals[i].FileSize.ToString(), "", locals[i].FullName);
            }
            foreach (UpdateItem item in servers)
            {
                for (int i = 0; i < gr.Length; i++)
                {
                    if (gr[i].FileName == item.FileName)
                    {
                        gr[i].sFileSize = item.FileSize.ToString();
                        gr[i].sModifyDate = item.ModifyDate.ToString();
                        break;
                    }
                }
            }
            for (int i = 0; i < gr.Length; i++)
            {
                if (gr[i].sFileSize == "" || gr[i].sModifyDate == "" || DateTime.Parse(gr[i].sModifyDate) < DateTime.Parse(gr[i].lModifyDate))
                {
                    gr[i].Check = true;
                }
                if (gr[i].FileName.ToUpper() == System.IO.Path.GetFileName(Application.ExecutablePath).ToUpper())
                {
                    gr[i].Check = true;
                }
            }
            grid.PrimaryGrid.DataSource = gr;
        }
Пример #2
0
        public static void GetLocalFilesInfo(Updates localFiles, DirectoryInfo di)
        {
            FileInfo[] fis = di.GetFiles();
            foreach (FileInfo fi in fis)
            {
                if (".PDB .XML".Contains(fi.Extension.ToUpper()))
                {
                    continue;
                }

                UpdateItem item = new UpdateItem();
                item.FullName   = fi.FullName;
                item.FileName   = GetRelativePath(Application.StartupPath, fi.FullName);
                item.FileSize   = fi.Length;
                item.ModifyDate = fi.LastWriteTime;
                localFiles.Add(item);
            }
            DirectoryInfo[] dis = di.GetDirectories();
            foreach (DirectoryInfo dinfo in dis)
            {
                GetLocalFilesInfo(localFiles, dinfo);
            }
        }