// // GET: /Images/ public ActionResult Index () { //ContentResult contentResult1 = new ContentResult(); //contentResult1.Content = "Fehler - " + System.Web.HttpContext.Current.Application.Identity; //return contentResult1; ImageFolder viewFolder = new ImageFolder (); string msg = ""; FolderInfo folderInfo = new FolderInfo (); if (Configurations.ViewFolders.Count == 0) { msg = Configurations.Reload (); } if (Configurations.ViewFolders.Count != 0) { folderInfo.Folder = new DirectoryInfo (Configurations.ViewFolders [0].LocalFolderPath); folderInfo.WebUri = new Uri (Configurations.ViewFolders [0].WebFolderPath); folderInfo.ThumbsFolder = "Thumbs/"; viewFolder.AnalyzeFolder (folderInfo); return View ("FolderView", viewFolder); } ContentResult contentResult = new ContentResult (); contentResult.Content = "Fehler - " + msg; return contentResult; }
public ActionResult Ordner (string fInfo, string webUri, string thumbFolder) { ImageFolder viewFolder = new ImageFolder (); FolderInfo folderInfo = new FolderInfo (); folderInfo.Folder = new DirectoryInfo (fInfo); folderInfo.WebUri = new Uri (webUri); folderInfo.ThumbsFolder = thumbFolder; viewFolder.AnalyzeFolder (folderInfo); return View ("FolderView", viewFolder); }
public void AnalyzeFolder (FolderInfo folderInfo) { DirectoryInfo directoryInfo = folderInfo.Folder; Images = new List<ImageInfo> (); Folders = new List<FolderInfo> (); if (!folderInfo.WebUri.AbsolutePath.EndsWith ("/")) { folderInfo.WebUri = new Uri (folderInfo.WebUri.ToString () + "/"); } if (FolderValidator.ValidFolder (directoryInfo.Parent.FullName) != null) { FolderInfo foundFolderInfo = new FolderInfo (); foundFolderInfo.Folder = directoryInfo.Parent; foundFolderInfo.WebUri = new Uri ( folderInfo.WebUri.AbsoluteUri.Remove (folderInfo.WebUri.AbsoluteUri.Length - folderInfo.WebUri.Segments.Last ().Length)); foundFolderInfo.FolderName = "Zurück"; foundFolderInfo.ThumbsFolder = (folderInfo.ThumbsFolder.Substring (0, folderInfo.ThumbsFolder.LastIndexOf ("/"))); foundFolderInfo.ThumbsFolder = (foundFolderInfo.ThumbsFolder.Substring (0, foundFolderInfo.ThumbsFolder.LastIndexOf ("/") + 1)); Folders.Add (foundFolderInfo); } foreach (DirectoryInfo directory in directoryInfo.GetDirectories ()) { FolderInfo foundFolderInfo = new FolderInfo (); foundFolderInfo.Folder = directory; foundFolderInfo.WebUri = new Uri (folderInfo.WebUri, directory.Name); foundFolderInfo.ThumbsFolder = folderInfo.ThumbsFolder + directory.Name + "/"; foundFolderInfo.FolderName = directory.Name; Folders.Add (foundFolderInfo); } foreach ( FileInfo file in directoryInfo.GetFiles ("*.*").Where ( s => s.Name.ToLower ().EndsWith (".png") || s.Name.ToLower ().EndsWith (".jpg"))) { ImageInfo imgInfo = new ImageInfo (); imgInfo.File = file; imgInfo.WebUri = new Uri (folderInfo.WebUri, file.Name); imgInfo.ThumbUri = folderInfo.ThumbsFolder + file.Name; imgInfo.CheckThumbnail (); Images.Add (imgInfo); } }