private void GetLicenseFileList() { DirectoryInfo dInfo = new DirectoryInfo(LicensePath); if (!dInfo.Exists) { dInfo.Create(); } if (!LicenseFileList.Contains(NewLicenseString)) { LicenseFileList.Add(NewLicenseString); } FileInfo[] Files = dInfo.GetFiles(); foreach (FileInfo file in Files) { if (!LicenseFileList.Contains(file.Name)) { LicenseFileList.Add(file.Name); } } }
private void combobox_license_SelectionChanged(object sender, SelectionChangedEventArgs e) { string sourceFileName = ""; if (NewLicenseString.Equals(Selected)) { OpenFileDialog FileDialog = new OpenFileDialog(); if (FileDialog.ShowDialog() == true) { string sourceFilePath = FileDialog.FileName; sourceFileName = System.IO.Path.GetFileName(sourceFilePath); string destFilePath = System.IO.Path.Combine(LicensePath, sourceFileName); if (File.Exists(destFilePath)) { MessageBox.Show("Same file name exists, Please check your license file"); } else { try { File.Copy(sourceFilePath, destFilePath); LicenseFileList.Add(sourceFileName); Selected = sourceFileName; } catch { } } } else { Selected = ""; combobox_license.SelectedValue = ""; } } }