ZeroInstall.Publish.Capture.SnapshotDiff.GetInstallationDir C# (CSharp) Method

GetInstallationDir() private method

private GetInstallationDir ( ) : string
return string
        public string GetInstallationDir()
        {
            string installationDir;
            if (ProgramsDirs.Length == 0)
                throw new InvalidOperationException(Resources.NoInstallationDirDetected);
            else
            {
                if (ProgramsDirs.Length > 1)
                    Log.Warn(Resources.MultipleInstallationDirsDetected);

                installationDir = new DirectoryInfo(ProgramsDirs[0]).WalkThroughPrefix().FullName;
                Log.Info(string.Format(Resources.InstallationDirDetected, installationDir));
            }
            return installationDir;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Collects data from the locations indicated by the differences between the <see cref="Start"/> state and the current system state.
        /// </summary>
        /// <param name="handler">A callback object used when the the user needs to be informed about IO tasks.</param>
        /// <exception cref="InvalidOperationException">No installation directory was detected.</exception>
        /// <exception cref="OperationCanceledException">The user canceled the task.</exception>
        /// <exception cref="IOException">There was an error accessing the registry or file system.</exception>
        /// <exception cref="UnauthorizedAccessException">Access to the registry or file system was not permitted.</exception>
        public void Diff([NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (handler == null) throw new ArgumentNullException(nameof(handler));
            #endregion

            _diff = new SnapshotDiff(before: _snapshot, after: Snapshot.Take());
            if (string.IsNullOrEmpty(InstallationDir)) InstallationDir = _diff.GetInstallationDir();

            _feedBuilder.ImplementationDirectory = InstallationDir;
            _feedBuilder.DetectCandidates(handler);
        }
All Usage Examples Of ZeroInstall.Publish.Capture.SnapshotDiff::GetInstallationDir