コード例 #1
0
        public bool CheckForUpdates()
        {
            RemoteManifest.LoadFromUrl(Settings.Default.RemoteDeploymentManifest);

            string         rootDir   = Path.GetDirectoryName(Application.ExecutablePath) + "\\";
            string         localFile = "";
            DeploymentFile localDF;

            foreach (DeploymentFile df in RemoteManifest.Files)
            {
                if (Path.IsPathRooted(df.FileName))
                {
                    localFile = df.FileName;
                }
                else
                {
                    localFile = Path.Combine(rootDir, df.FileName);
                }

                if (!File.Exists(localFile))
                {
                    // This file is missing from the local system, updates are needed
                    FileUpdateList.Add(df);
                }
                else
                {
                    localDF = DeploymentFile.CreateFromFile(localFile);

                    if (localDF != df)
                    {
                        // This file does not match the remote manifest, updates are needed
                        FileUpdateList.Add(df);
                    }
                }
            }

            return(FileUpdateList.Count > 0); // Updates are needed if there are any files in this list
        }