SaveSdCard.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Microsoft.WindowsAPICodePack.Dialogs;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. namespace Phihong_EVSE_UI_Tool
  17. {
  18. /// <summary>
  19. /// SaveSdCard.xaml 的互動邏輯
  20. /// </summary>
  21. public partial class SaveSdCard : UserControl
  22. {
  23. private string sdFolderPath;
  24. public SaveSdCard()
  25. {
  26. InitializeComponent();
  27. }
  28. private void uxBrowseButton_Click(object sender, RoutedEventArgs e)
  29. {
  30. var dlg = new CommonOpenFileDialog()
  31. {
  32. IsFolderPicker = true,
  33. Title = "Locate the SD card",
  34. };
  35. if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
  36. {
  37. sdFolderPath = dlg.FileName;
  38. uxSdBrowseTextBox.Text = sdFolderPath;
  39. SaveToSdCard();
  40. }
  41. }
  42. private void SaveToSdCard()
  43. {
  44. Directory.CreateDirectory(Path.Combine(sdFolderPath, Utility.SDCARD_SUBDIR));
  45. foreach (string fileName in Utility.FILES_LIST)
  46. {
  47. File.Copy(Path.Combine(Utility.OUTPUT_DIRECTORY, fileName),
  48. Path.Combine(sdFolderPath, Utility.SDCARD_SUBDIR, fileName), true);
  49. }
  50. }
  51. }
  52. }