操作bin目录下的文件

时间:2022-01-13 04:27:33

string dir = AppDomain.CurrentDomain.BaseDirectory + "Video";
if (!System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
DirectoryInfo root = new DirectoryInfo(dir);
FileInfo[] files = root.GetFiles();

if (files.Length > 0)
{
this.mediaElement.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "Video\\" + files[0], UriKind.Relative);
}
else
{
MessageBox.Show("无法找到视频文件!");
}