diff --git a/Video.xaml b/Video.xaml
index 601de7f..12155af 100644
--- a/Video.xaml
+++ b/Video.xaml
@@ -25,7 +25,7 @@
-
+
diff --git a/Video.xaml.cs b/Video.xaml.cs
index 8961f47..997ec8d 100644
--- a/Video.xaml.cs
+++ b/Video.xaml.cs
@@ -1,4 +1,6 @@
-using Microsoft.Win32;
+using Microsoft.Expression.Drawing.Core;
+using Microsoft.Extensions.Logging;
+using Microsoft.Win32;
using System.IO;
using System.Windows;
@@ -11,21 +13,54 @@ namespace VideoConcat
public partial class Video : Window
{
public string text = "";
+ public FileSystemInfo[]? Floders { get; set; }
+ public string[] Heads = [];
+ public string[] Tails = [];
+ public string[] Middles = [];
+
+ public DirectoryInfo? Path { get; set; }
+
+
public Video()
{
InitializeComponent();
- Check_Folder();
+
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
+
+ int count = 0;
+ try
+ {
+ count = int.Parse(videoCount.Text);
+ }
+ catch (Exception)
+ {
+
+ MessageBox.Show("请输入正确的数字");
+ return;
+ }
+
+ WriteTxt($"生成视频的个数:{videoCount.Text} 个");
+
+ Check_Folder();
+
+
startButton.IsEnabled = false;
+
+ Array.ForEach(array: Middles, s =>
+ {
+ WriteTxt(s);
+ });
+
await Task.Run(() =>
{
- for (int i = 0; i <= 100; i++)
+
+ for (int i = 0; i <= count; i++)
{
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
@@ -54,34 +89,44 @@ namespace VideoConcat
{
string currentPath = Directory.GetCurrentDirectory();
- DirectoryInfo? parentPathInfo = Directory.GetParent(currentPath);
- if (parentPathInfo == null)
+ Path = Directory.GetParent(currentPath);
+ if (Path == null)
{
WriteTxt("获取相关视频文件目录失败!");
return;
}
- WriteTxt("当前目录为:" + parentPathInfo.FullName);
+ WriteTxt("当前目录为:" + Path.FullName);
try
{
Boolean hasHead = false;
Boolean hasTail = false;
- DirectoryInfo dirD = parentPathInfo as DirectoryInfo;
- FileSystemInfo[] folders = dirD.GetDirectories();//获取文件夹下所有文件和文件夹
- //对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
+ DirectoryInfo dirD = Path as DirectoryInfo;
+ //获取文件夹下所有文件夹
+ Floders = dirD.GetDirectories();
- foreach (FileSystemInfo folder in folders)
+ //对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
+
+ foreach (FileSystemInfo folder in Floders)
{
WriteTxt($"{folder.Name}");
if (folder.Name == "head")
{
hasHead = true;
+ Heads = GetAllVideos($"{Path}\\{folder.Name}");
+ continue;
+
}
if (folder.Name == "tail")
{
hasTail = true;
+ Tails = GetAllVideos($"{Path}\\{folder.Name}");
+ continue;
}
+
+ Middles = Middles.Concat(GetAllVideos($"{Path}\\{folder.Name}")).ToArray();
+
}
if (!hasHead)
{
@@ -106,5 +151,10 @@ namespace VideoConcat
outputTxt.Text = text;
scrowText.ScrollToEnd();
}
+
+ public static string[] GetAllVideos(string path)
+ {
+ return Directory.GetFiles(path, "*.mp4", SearchOption.AllDirectories);
+ }
}
}