/// <summary> /// Loads the driver package and saves it in the cache. /// </summary> /// <param name="driversDirectory">Location of the driver distribution.</param> /// <param name="includeAllArchitectures">if set to <c>true</c> all architectures are included.</param> public void LoadDrivers(string driversDirectory, bool includeAllArchitectures) { // Clear out the print drivers when loading a new set of drivers. _printDrivers.Clear(); _propertiesSet.Clear(); var drivers = DriverController.LoadFromDirectory(driversDirectory, includeAllArchitectures); foreach (DriverDetails driver in drivers) { AddDriver(new PrintDeviceDriver(driver)); } }
/// <summary> /// Blocking method that scans for inbox drivers within the driver store repository. /// </summary> private void ScanForInboxDrivers() { // This has to scan according to the proper location for the INF files. _drivers.Clear(); string inboxPath = string.Empty; // Assume that for Vista or greater the DriverStore is used... if (Environment.OSVersion.Version.Major >= 6) { inboxPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"DriverStore\FileRepository"); } else { inboxPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "inf"); } TraceFactory.Logger.Debug("Crawling {0}".FormatWith(inboxPath)); if (Directory.Exists(inboxPath)) { var directories = Directory.GetDirectories(inboxPath); // Include one extra directory to account for the top level directory which // is searched as a separate call below. _totalDirectories = directories.Count() + 1; TraceFactory.Logger.Debug("Directory Count: {0}".FormatWith(_totalDirectories)); // Search all the children of the root. foreach (string directory in directories) { _drivers.Add(LoadDrivers(directory, false, SearchOption.AllDirectories)); if (_tokenSource.IsCancellationRequested) { TraceFactory.Logger.Debug("Cancellation received, returning..."); return; } } // Search the root directory, but don't drill down into the children, they've // already been done. _drivers.Add(LoadDrivers(inboxPath, false, SearchOption.TopDirectoryOnly)); Thread.Sleep(TimeSpan.FromSeconds(1)); if (_tokenSource.IsCancellationRequested) { TraceFactory.Logger.Debug("Cancellation received, returning..."); return; } } if (OnAllDriversLoaded != null) { if (_tokenSource.IsCancellationRequested) { TraceFactory.Logger.Debug("Cancellation received, returning..."); return; } OnAllDriversLoaded(this, new EventArgs()); } _scanningComplete = true; }