public static void Remove_UriAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, "authenticationType"); cc.Remove(new Uri("http://some.com"), null); cc.Remove(new Uri("http://some.com"), "authenticationType"); }
public static void Remove_UriAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, "authenticationType"); cc.Remove(new Uri("http://some.com"), null); Assert.Throws <KeyNotFoundException>(() => cc.Remove(new Uri("http://non.existant"), "invalid-authentication-type")); //No such credential }
public static void Remove_HostPortAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, 500, "authenticationType"); cc.Remove("host", 500, null); cc.Remove("host", -1, "authenticationType"); cc.Remove("host", 500, "authenticationType"); }
public static void Remove_HostPortAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, 500, "authenticationType"); cc.Remove("host", 500, null); cc.Remove("host", -1, "authenticationType"); Assert.Throws <KeyNotFoundException>(() => cc.Remove("invalid-host", 500, "invalid-authentication-type")); //No such credential }
private void UpdateCredentialsCache(NetworkCredential credentials) { var pxyCfg = Config.Instance.ProxyConfig; _authCache.Remove(pxyCfg.ProxySettings.ProxyUri, "Basic"); _authCache.Add(pxyCfg.ProxySettings.ProxyUri, "Basic", credentials); }
public static void Remove_UriAuthenticationType_Success() { CredentialCache cc = UriAuthenticationTypeCredentialCache(); cc.Remove(uriPrefix1, authenticationType1); Assert.Null(cc.GetCredential(uriPrefix1, authenticationType1)); }
public static void Remove_HostPortAuthenticationType_Success() { CredentialCache cc = HostPortAuthenticationTypeCredentialCache(); cc.Remove(host1, port1, authenticationType1); Assert.Null(cc.GetCredential(host1, port1, authenticationType1)); }
public static void LogoutOfUNCShare(string username, string password, string domain, string share) { NetworkCredential theNetworkCredential = new NetworkCredential(username, password, domain); CredentialCache theNetCache = new CredentialCache(); //theNetCache.Add(new Uri(@"\\" + share), "Basic", theNetworkCredential); theNetCache.Remove(new Uri(@"\\" + share), "Basic"); }
private static void InvalidateUserCredentials(string username) { if (CredentialCache.ContainsKey(username)) { CredentialCache.Remove(username); } DeleteDatabaseCredentials(ProtectUsername(username)); }
/// <summary> /// /// </summary> /// <param name="uri"></param> /// <param name="authenticationType"></param> /// <param name="networkCredential"></param> public void AddCredentials(Uri uri, string authenticationType, NetworkCredential networkCredential) { var existingCredential = CredentialCache.GetCredential(uri, authenticationType); if (existingCredential != null) { CredentialCache.Remove(uri, authenticationType); } CredentialCache.Add(uri, authenticationType, networkCredential); }
public void SetCredentials(ConnectionProfile profile, NetworkCredential credentials, string authType) { var creds = _credentialCache.GetCredential(profile.Uri, authType); if (creds != null) { _credentialCache.Remove(profile.Uri, authType); } _credentialCache.Add(profile.Uri, authType, credentials); }
void AddCredential(Uri uri, DiscoveryNetworkCredential credential) { NetworkCredential matchedCredential = credentialCache.GetCredential(uri, credential.AuthenticationType); if (matchedCredential != null) { credentialCache.Remove(uri, credential.AuthenticationType); } credentialCache.Add(uri, credential.AuthenticationType, credential); }
//送信部実体、サーバーにPOSTし文字列を取得する。 private async Task <string> PostHttpRequestAsync(string uri, FormUrlEncodedContent content) { string strres; try { //送信処理が完了しない間は送信を待つ。 await WaitIdleAsync(); _isBusy = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; _credCache.Remove(new Uri(uri), this.ServerInfo.AuthType); _credCache.Add(new Uri(uri), this.ServerInfo.AuthType, new NetworkCredential(this.ServerInfo.AuthUser, this.ServerInfo.AuthPass)); #if MAKE_DELAY_SERVER var response = await _httpClient.PostAsync(uri, content); await Task.Delay(1000); var strres = await response.Content.ReadAsStringAsync(); await Task.Delay(1000); #else var response = await _httpClient.PostAsync(uri, content); strres = await response.Content.ReadAsStringAsync(); #endif } finally { _isBusy = false; } return(strres); async Task <bool> WaitIdleAsync() { //_isBusyがtrueの間はループで待つ(0.2秒間隔で確認) return(await Task.Run(async() => { while (true) { if (_isBusy != true) { return true; } await Task.Delay(200); } }).Timeout(TimeSpan.FromSeconds(SessionTimeOutSecond))); } }
public static void Init(string apiKey, string apiUrl) { _apiUrl = apiUrl; if (!_apiUrl.EndsWith("/")) { _apiUrl += "/"; } _cc = new CredentialCache(); Uri url = new Uri(_apiUrl); _cc.Remove(url, "Basic"); _cc.Add(url, "Basic", new NetworkCredential("api_key", apiKey)); }
public static void AddRemove_HostPortAuthenticationTypeDefaultCredentials_Success() { NetworkCredential nc = CredentialCache.DefaultNetworkCredentials as NetworkCredential; CredentialCache cc = new CredentialCache(); cc.Add(host1, port1, authenticationType1, nc); Assert.Equal(nc, cc.GetCredential(host1, port1, authenticationType1)); cc.Remove(host1, port1, authenticationType1); Assert.Null(cc.GetCredential(host1, port1, authenticationType1)); }
public static void AddRemove_UriAuthenticationType_Success() { NetworkCredential nc = customCredential; CredentialCache cc = new CredentialCache(); cc.Add(uriPrefix1, authenticationType1, nc); Assert.Equal(nc, cc.GetCredential(uriPrefix1, authenticationType1)); cc.Remove(uriPrefix1, authenticationType1); Assert.Null(cc.GetCredential(uriPrefix1, authenticationType1)); }
public static void GetPage(string url, string userName, string password, string domainName) { try { // <Snippet1> // <Snippet2> CredentialCache myCredentialCache = new CredentialCache(); // Used Dummy names as credentials. They are to be replaced by credentials applicable locally. myCredentialCache.Add(new Uri("http://www.microsoft.com/"), "Basic", new NetworkCredential("user1", "passwd1", "domain1")); myCredentialCache.Add(new Uri("http://www.msdn.com/"), "Basic", new NetworkCredential("user2", "passwd2", "domain2")); myCredentialCache.Add(new Uri(url), "Basic", new NetworkCredential(userName, password, domainName)); Console.WriteLine("\nAdded your credentials to the program's CredentialCache"); // </Snippet2> // <Snippet3> // Create a webrequest with the specified url. WebRequest myWebRequest = WebRequest.Create(url); myWebRequest.Credentials = myCredentialCache; Console.WriteLine("\nLinked CredentialCache to your request."); // Send the request and wait for response. WebResponse myWebResponse = myWebRequest.GetResponse(); // </Snippet1> // Process response here. Console.Write("Response received successfully."); // Call 'Remove' method to dispose credentials for current Uri as not required further. myCredentialCache.Remove(myWebRequest.RequestUri, "Basic"); Console.WriteLine("\nYour credentials have now been removed from the program's CredentialCache"); myWebResponse.Close(); // </Snippet3> } catch (WebException e) { if (e.Response != null) { Console.WriteLine("\r\nFailed to obtain a response. The following error occurred : {0}", ((HttpWebResponse)(e.Response)).StatusDescription); } else { Console.WriteLine("\r\nFailed to obtain a response. The following error occurred : {0}", e.Status); } } catch (Exception e) { Console.WriteLine("\nThe following exception was raised : {0}", e.Message); } }
private void InfoWorker_DoWork(object sender, DoWorkEventArgs e) { CredentialCache netCache = new CredentialCache(); try { netCache.Add(new Uri(string.Format(@"\\{0}", PropertyManager["Name"].StringValue)), "Digest", CredentialCache.DefaultNetworkCredentials); string clientHealthFile = string.Format(@"\\{0}\admin$\CCM\CcmEvalReport.xml", PropertyManager["Name"].StringValue); if (File.Exists(clientHealthFile)) { XElement clientHealth = XElement.Load(clientHealthFile); XNamespace ns = clientHealth.GetDefaultNamespace(); foreach (XElement node in clientHealth.Descendants(ns + "HealthCheck")) { listViewClientHealth.Items.Add(new ListViewItem() { Text = node.Attribute("Description").Value, SubItems = { node.Value } }); } XElement summary = clientHealth.Descendants(ns + "Summary").First(); if (summary != null) { DateTimeFormatInfo formatInfo = CultureInfo.CurrentUICulture.DateTimeFormat; DateTime time = DateTime.Parse(summary.Attribute("EvaluationTime").Value); labelLastScan.Text = time.ToString(formatInfo); } } else { labelLastScan.Text = "CcmEvalReport.xml has not been generated"; } } catch (Exception ex) { throw new InvalidOperationException(string.Format("{0}: {1}", ex.GetType().Name, ex.Message)); } finally { netCache.Remove(new Uri(string.Format(@"\\{0}", PropertyManager["Name"].StringValue)), "Digest"); } }
/// <summary> /// </summary> /// <param name="host"></param> /// <param name="oauthToken"></param> public void AddOAuthCredentials(Uri host, string oauthToken) { Logging.Info("Adding OAuth Credentials"); Logging.Debug("Host: {0}", new object[] { host }); try { var existingCredentials = CredentialCache.GetCredential(host, "Bearer"); if (existingCredentials != null) { CredentialCache.Remove(host, "Bearer"); } } catch (Exception exception) { Logging.Error(exception, "Failed to add OAuth credentials"); } finally { CredentialCache.Add(host, "Bearer", new OAuth2Credential(oauthToken)); } }
public void All() { CredentialCache c = new CredentialCache(); NetworkCredential cred1 = new NetworkCredential("user1", "pwd1"); NetworkCredential cred2 = new NetworkCredential("user2", "pwd2"); NetworkCredential cred3 = new NetworkCredential("user3", "pwd3"); NetworkCredential cred4 = new NetworkCredential("user4", "pwd4"); NetworkCredential cred5 = new NetworkCredential("user5", "pwd5"); c.Add(new Uri("http://www.ximian.com"), "Basic", cred1); c.Add(new Uri("http://www.ximian.com"), "Kerberos", cred2); c.Add(new Uri("http://www.contoso.com/portal/news/index.aspx"), "Basic", cred1); c.Add(new Uri("http://www.contoso.com/portal/news/index.aspx?item=1"), "Basic", cred2); c.Add(new Uri("http://www.contoso.com/portal/news/index.aspx?item=12"), "Basic", cred3); c.Add(new Uri("http://www.contoso.com/portal/"), "Basic", cred4); c.Add(new Uri("http://www.contoso.com"), "Basic", cred5); NetworkCredential result = null; try { c.Add(new Uri("http://www.ximian.com"), "Basic", cred1); Assert.Fail("#1: should have failed"); } catch (ArgumentException) { } c.Add(new Uri("http://www.contoso.com/"), "**Unknown**", cred1); result = c.GetCredential(new Uri("http://www.contoso.com/"), "**Unknown**"); Assert.AreEqual(result, cred1, "#3"); c.Remove(new Uri("http://www.contoso.com/"), "**Unknown**"); result = c.GetCredential(new Uri("http://www.contoso.com/"), "**Unknown**"); Assert.IsTrue(result == null, "#4"); c.Add(new Uri("http://www.contoso.com/"), "**Unknown**", cred1); result = c.GetCredential(new Uri("http://www.contoso.com"), "**Unknown**"); Assert.AreEqual(result, cred1, "#5"); c.Remove(new Uri("http://www.contoso.com"), "**Unknown**"); result = c.GetCredential(new Uri("http://www.contoso.com"), "**Unknown**"); Assert.IsTrue(result == null, "#6"); c.Add(new Uri("http://www.contoso.com/portal/"), "**Unknown**", cred1); result = c.GetCredential(new Uri("http://www.contoso.com/portal/foo/bar.html"), "**Unknown**"); Assert.AreEqual(result, cred1, "#7"); c.Remove(new Uri("http://www.contoso.com"), "**Unknown**"); result = c.GetCredential(new Uri("http://www.contoso.com"), "**Unknown**"); Assert.IsTrue(result == null, "#8"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/news/index.aspx"), "Basic"); Assert.AreEqual(result, cred3, "#9"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/news/index"), "Basic"); Assert.AreEqual(result, cred3, "#10"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/news/"), "Basic"); Assert.AreEqual(result, cred3, "#11"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/news"), "Basic"); Assert.AreEqual(result, cred4, "#12"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/ne"), "Basic"); Assert.AreEqual(result, cred4, "#13"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal/"), "Basic"); Assert.AreEqual(result, cred4, "#14"); result = c.GetCredential(new Uri("http://www.contoso.com:80/portal"), "Basic"); Assert.AreEqual(result, cred5, "#15"); result = c.GetCredential(new Uri("http://www.contoso.com:80/"), "Basic"); Assert.AreEqual(result, cred5, "#16"); result = c.GetCredential(new Uri("http://www.contoso.com"), "Basic"); Assert.AreEqual(result, cred5, "#17"); /* * IEnumerator e = c.GetEnumerator (); * while (e.MoveNext ()) { * Console.WriteLine (e.Current.GetType () + " : " + e.Current.ToString ()); * } */ #if NET_2_0 result = c.GetCredential("www.ximian.com", 80, "Basic"); Assert.IsTrue(result == null, "#18"); c.Add("www.ximian.com", 80, "Basic", cred1); try { c.Add("www.ximian.com", 80, "Basic", cred1); Assert.Fail("#19: should have failed"); } catch (ArgumentException) { } result = c.GetCredential("www.ximian.com", 80, "Basic"); Assert.AreEqual(result, cred1, "#20"); c.Remove(new Uri("http://www.contoso.com"), "Basic"); c.Add("www.contoso.com", 80, "Basic", cred5); result = c.GetCredential(new Uri("http://www.contoso.com"), "Basic"); Assert.IsTrue(result == null, "#21"); #endif }
public void RemoveCredentials(Uri uri, string authenticationType) { CredentialCache.Remove(uri, authenticationType); }
public static void Remove_UriAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, "authenticationType"); cc.Remove(new Uri("http://some.com"), null); Assert.Throws<KeyNotFoundException>(() => cc.Remove(new Uri("http://non.existant"), "invalid-authentication-type")); //No such credential }
public static void Remove_HostPortAuthenticationType_Invalid() { CredentialCache cc = new CredentialCache(); //Doesn't throw, just returns cc.Remove(null, 500, "authenticationType"); cc.Remove("host", 500, null); cc.Remove("host", -1, "authenticationType"); Assert.Throws<KeyNotFoundException>(() => cc.Remove("invalid-host", 500, "invalid-authentication-type")); //No such credential }
/// <summary> /// Submit HTTP Request /// </summary> /// <remarks> /// Submit an HTTP request. /// </remarks> /// <param name="method">HTTP Method. for example "POST", "GET"</param> /// <param name="URL">URL to send HTTP Request to</param> /// <param name="postdata">Data to be posted</param> /// <param name="usr">Username</param> /// <param name="pwd">Password</param> /// <returns>Response in plain text.</returns> public string SubmitHttpRequest(string method, string URL, string postdata, string usr, string pwd) { String responseText = ""; HttpWebRequest request; Uri uri = new Uri(URL); request = (HttpWebRequest)WebRequest.Create(uri); request.AllowAutoRedirect = true; if (method.Equals("SOAP")) { request.Method = "POST"; request.Headers.Add("SOAPAction: Some-URI"); request.ContentType = "text/xml; charset=UTF-8"; } else if (method.Equals("DOWNLOAD")) { request.Method = "GET"; } else { request.ContentType = "text/xml; charset=UTF-8"; request.Method = method; } // Credential and cookies request.CookieContainer = _cookieContainer; NetworkCredential nc = null; String authType = "Negotiate"; if (_credentialCache.GetCredential(uri, authType) == null && _credentialCache.GetCredential(uri, "Basic") == null) { if (!String.IsNullOrEmpty(usr) && !String.IsNullOrEmpty(pwd)) { nc = new NetworkCredential(usr, pwd); _credentialCache.Add(uri, "Basic", nc); _credentialCache.Add(uri, authType, nc); } else { nc = System.Net.CredentialCache.DefaultNetworkCredentials; _credentialCache.Add(uri, authType, nc); } } request.Credentials = _credentialCache; // post data if (request.Method.Equals("POST", StringComparison.OrdinalIgnoreCase)) { UTF8Encoding encoding = new UTF8Encoding(); Byte[] byteTemp = encoding.GetBytes(postdata); request.ContentLength = byteTemp.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(byteTemp, 0, byteTemp.Length); requestStream.Close(); } HttpWebResponse response = null; try{ response = (HttpWebResponse)request.GetResponse(); } catch (UnauthorizedAccessException ua) { if (retryAttempt) { PromptCredentials pc = new PromptCredentials(); pc.ShowDialog(); retryAttempt = false; try { _credentialCache.Remove(uri, "Basic"); } catch (Exception) { }; _credentialCache.Remove(uri, authType); if (!String.IsNullOrEmpty(pc.Username) && !String.IsNullOrEmpty(pc.Password)) { return(SubmitHttpRequest(method, URL, postdata, pc.Username, pc.Password)); } else { return(null); } } else { retryAttempt = true; throw ua; } } catch (WebException we) { if (retryAttempt) { PromptCredentials pc = new PromptCredentials(); pc.ShowDialog(); retryAttempt = false; try { _credentialCache.Remove(uri, "Basic"); }catch (Exception) {}; _credentialCache.Remove(uri, authType); if (!String.IsNullOrEmpty(pc.Username) && !String.IsNullOrEmpty(pc.Password)) { return(SubmitHttpRequest(method, URL, postdata, pc.Username, pc.Password)); } else { return(null); } } else { retryAttempt = true; throw we; } } if (_cookieContainer.GetCookies(uri) == null) { _cookieContainer.Add(uri, response.Cookies); } Stream responseStream = response.GetResponseStream(); if (method.Equals("DOWNLOAD")) { FileStream file = null; string fileName = response.GetResponseHeader("Content-Disposition"); string[] s = null; if (fileName.ToLower().EndsWith(".tif")) { s = URL.Split(new String[] { "coverage=" }, 100, StringSplitOptions.RemoveEmptyEntries); s[1] = s[1].Trim() + ".tif"; } else { s = fileName.Split('='); s[1] = s[1].Replace('\\', ' '); s[1] = s[1].Replace('"', ' '); s[1] = s[1].Trim(); } try { downloadFileName = System.IO.Path.Combine(Utils.GetSpecialFolderPath(SpecialFolder.ConfigurationFiles), s[1]); System.IO.File.Delete(downloadFileName); file = System.IO.File.Create(downloadFileName); // Buffer to read 10K bytes in chunk: byte[] buffer = new Byte[10000]; int length = 10000; int offset = 0; while (length > 0) { length = responseStream.Read(buffer, 0, length); offset += length; file.Write(buffer, 0, length); } } catch (Exception e) {} finally { if (file != null) { file.Close(); } if (responseStream != null) { responseStream.Close(); } retryAttempt = true; } return(downloadFileName); } StreamReader reader = new StreamReader(responseStream); responseText = reader.ReadToEnd(); reader.Close(); responseStream.Close(); return(responseText); }
// this is providing us with XS1 data objects in result of XS1 events public void Run() { while (running) { try { byte[] buf = new byte[8192]; String HacsURL = "http://" + ServerName + "/control?callback=cname&cmd=subscribe&format=tsv"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HacsURL); request.Timeout = 60000; request.Credentials = new NetworkCredential(UserName, Password); String _UsernameAndPassword = UserName + ":" + Password; Uri _URI = new Uri(HacsURL); CredentialCache _CredentialCache = new CredentialCache(); _CredentialCache.Remove(_URI, "Basic"); _CredentialCache.Add(_URI, "Basic", new NetworkCredential(UserName, Password)); String _AuthorizationHeader = "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(_UsernameAndPassword)); request.Headers.Add("Authorization", _AuthorizationHeader); // execute the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { AcceptingCommands = true; ConsoleOutputLogger.WriteLineToScreenOnly("XS1 successfully connected!"); } // we will read data via the response stream Stream resStream = response.GetResponseStream(); string tempString = null; int count = 0; do { #region XS1 Receiving and Queue stuffing // fill the buffer with data count = resStream.Read(buf, 0, buf.Length); // make sure we read some data if (count != 0) { // translate from bytes to ASCII text tempString = Encoding.ASCII.GetString(buf, 0, count); XS1_DataObject dataobject = HandleXS1_TSV.HandleValue(tempString); dataobject.ServerName = ServerName; dataobject.OriginalXS1Statement = tempString; iQueue.Enqueue(dataobject); // add it to the queue } #endregion }while (count > 0); // any more data to read? } catch (Exception) { AcceptingCommands = false; Thread.Sleep(1); } } }
/// <inheritdoc /> public void Remove(string host, int port, string authenticationType) { _cache.Remove(host, port, authenticationType); }
public override void PostApply(BackgroundWorker worker, DoWorkEventArgs e) { try { Dictionary <string, string> error = new Dictionary <string, string>(); List <string> successful = new List <string>(); var parser = new FileIniDataParser(); parser.Parser.Configuration.AllowDuplicateKeys = true; parser.Parser.Configuration.AllowDuplicateSections = true; parser.Parser.Configuration.SkipInvalidLines = true; parser.Parser.Configuration.CaseInsensitive = true; string sourceFolder = labelDestination.Text; string destinationFolder = Path.Combine(sourceFolder, textBoxDestination.Text); CredentialCache netCache = new CredentialCache(); try { netCache.Add(new Uri(sourceFolder), "Digest", CredentialCache.DefaultNetworkCredentials); netCache.Add(new Uri(string.Format(@"\\{0}", PropertyManager["Name"].StringValue)), "Digest", CredentialCache.DefaultNetworkCredentials); } catch (IOException ex) { throw new InvalidOperationException(string.Format("{0}: {1}", ex.GetType().Name, ex.Message)); } if (!Directory.Exists(destinationFolder)) { Directory.CreateDirectory(destinationFolder); } int num = 0; List <ManagementObject> drivers = (List <ManagementObject>)UserData["DriverItems"]; foreach (ManagementObject driver in drivers) { int percent = num * 100 / drivers.Count; try { string driverFolder = Path.Combine(destinationFolder, driver["DeviceClass"].ToString(), driver["DeviceName"].ToString(), driver["DriverVersion"].ToString()); if (!Directory.Exists(driverFolder)) { Directory.CreateDirectory(driverFolder); } string infFile = driver["InfName"].ToString(); string remoteFolder = string.Format(@"\\{0}\admin$", PropertyManager["Name"].StringValue); string remoteINFFile = Path.Combine(remoteFolder, "inf", infFile); string inf = Path.Combine(driverFolder, infFile); if (!File.Exists(inf)) { File.Copy(remoteINFFile, inf); } IniData iniData = parser.ReadFile(inf); string catalogFile = GetCatalog(iniData); foreach (string file in Directory.GetFiles(Path.Combine(remoteFolder, @"System32\DriverStore\FileRepository"), catalogFile, SearchOption.AllDirectories)) { FileInfo fileInfo = new FileInfo(file); if (!File.Exists(Path.Combine(driverFolder, fileInfo.Name))) { File.Copy(file, Path.Combine(driverFolder, fileInfo.Name)); } KeyDataCollection sourceDisksFiles; if (architecture == "x86") { sourceDisksFiles = iniData["SourceDisksFiles.x86"]; } else { sourceDisksFiles = iniData["SourceDisksFiles.amd64"]; } if (sourceDisksFiles == null) { sourceDisksFiles = iniData["SourceDisksFiles"]; } foreach (KeyData key in sourceDisksFiles) { if (key.KeyName.Split('.').Length > 1) { string copyFile = Path.Combine(fileInfo.DirectoryName.ToString(), key.KeyName); if (File.Exists(copyFile) && !File.Exists(Path.Combine(driverFolder, key.KeyName))) { worker.ReportProgress(percent, string.Format("Processing Driver: {0}\n Copying File: {1}", driver["DeviceName"].ToString(), key.KeyName)); File.Copy(copyFile, Path.Combine(driverFolder, key.KeyName)); } } } foreach (string path in Directory.GetDirectories(fileInfo.DirectoryName.ToString())) { DirectoryInfo source = new DirectoryInfo(path); worker.ReportProgress(percent, string.Format("Processing Driver: {0}\n Copying Folder: {1}", driver["DeviceName"].ToString(), source.Name)); string target = Path.Combine(driverFolder, source.Name); Utility.Copy(path, target); } } successful.Add(driver["DeviceName"].ToString()); } catch (Exception ex) { error.Add("Could not capture driver: " + ex.Message, driver["DeviceName"].ToString()); } num++; } PrepareCompletion(successful, error); base.PostApply(worker, e); } catch (Exception ex) { PrepareError(ex.Message); throw; } finally { CredentialCache netCache = new CredentialCache(); netCache.Remove(new Uri(labelDestination.Text), "Digest"); netCache.Remove(new Uri(string.Format(@"\\{0}", PropertyManager["Name"].StringValue)), "Digest"); } }