这是我现在使用的代码:
private void words(string path)
{
List<string> text = new List<string>();
var intro = "Video File Name:";
var words = File.ReadAllLines(path)
.Where(line => line.StartsWith(intro))
.Select(line => line.Substring(intro.Length).Trim());
}
变量路径是文本文件的链接。这是文本文件的内容格式:
Video File Name: MVI_4523.MOV
Lightning Start Location At Frame: 11 Lightning End Location At Frame: 15
Lightning Start Location At Frame: 6 Lightning End Location At Frame: 15
Video File Name: MVI_4524.MOV
Lightning Start Location At Frame: 15 Lightning End Location At Frame: 19
Lightning Start Location At Frame: 4 Lightning End Location At Frame: 19
我想要做的是将文本文件中的所有视频文件名称解析List<string>
为例如列表内容将是:
索引[0] MVI_4523.MOV
索引[1] MVI_4524.MOV
然后我想遍历列表并将每个索引与我拥有的变量进行比较:like string variable =videoFile
例如:
for (int i = 0; i < videosfilesnames.Length; i++)
{
if (videosfilesnames[i] == videoFile)
{
// Here I want to extract from the text file the lightnings values that are belong to the matched video file name for example if MVI_4524.MOV was == to videoFile so here i want to extract the values from the text file: 15 19 and 4 19
// Then in the end i need to create/draw point red point on the locations 15 to 19 and 4 to 19
// So when extracting the values I need to be able to know that 15 is start and 19 end.
}
}