こんにちは、c# を使用して mvc4 のプロジェクトを行っています。ディレクトリ内のすべてのサブディレクトリを取得しようとしています。ビューにリストします
そのために私は次のコードを書いています
コントローラ
public ActionResult Gallery()
{
string folderpath = Server.MapPath("~/Content/Gallery/GalleryImages");
List<string> currentimage = new Gallery().GetGalleryName(folderpath);
//What will be the return type???/
return View(currentimage);
}
モデル
public List<string> GetGalleryName(string path)
{
DirectoryInfo di = new DirectoryInfo(path);
DirectoryInfo[] subdir = di.GetDirectories();
List<String> files = new List<String>();
foreach (DirectoryInfo dir in subdir)
{
var name = dir.Name;
files.Add(name);
}
return files;
}
私のコードは正しいですか?では、コントローラーとモデルの戻り値の型はどうなるでしょうか? 私を助けてください