New to .net MVC here. I am trying to scan a folder I added to my project labeled MovieMedia and add the name and file path with extension to my existing movie database. Im not sure how to do this. Currently I am adding each one in the seed method this way
new Movies
{
Title = "Jurassic Park",
FilePath = @"~/MovieMedia/Jurassic Park.mp4"
}
or by manually adding the details on a create page.
The goal here is to get the title and path to each movie already in the MovieMedia folder.
You can use below method to get all file list with path, you have to pass directory path as parameter.
public List<String> DirSearch(string sDir)
{
List<String> files = new List<String>();
foreach (string f in Directory.GetFiles(sDir))
{
files.Add(f);
}
foreach (string d in Directory.GetDirectories(sDir))
{
files.AddRange(DirSearch(d));
}
return files;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.