Regex in filepath

99 Views Asked by At

can u help me with regex in FFMpegConverter?

I have a bitmaps a saving them like it:

 foreach (Bitmap printscreen in printscreeny)
  {
    printscreen.Save(Path.GetTempPath()  + guid +"_"+ i);
    i++;
  }

then I want to convert them by NReco videoConverter but dont know how to write regex part to describe path.

I have it like it:

 videoConverter.ConvertMedia(Path.GetTempPath()  + guid + "_"+" *%d.bmp", null,"test.mp4", null, convertSettings);

Thanks

1

There are 1 best solutions below

1
On

One way to do this would be to keep track of the files in a list:

private List<string> unconvertedFiles = new List<string>();

Then you can add the file paths to this list when you save them:

// Save files
foreach (Bitmap printscreen in printscreeny)
{
    var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".bmp");
    printscreen.Save(path);

    // Add this path to our list for converting
    unconvertedFiles.Add(path);
}

And now later, when you want to process the files, you can just get the paths from your list (and remove them from the list when you're done):

// Process files
foreach (var path in unconvertedFiles.ToList())
{
    videoConverter.ConvertMedia(path, null, "test.mp4", null, convertSettings);

    // Remove it from our list so we don't process it again
    unconvertedFiles.Remove(path);
}