/// <summary> /// 動画の件数をカウントする、通常はxx(zz)件だが舞ワイフはxx(yy)/xx(yy)の形式でリターン(xxはwmvファイル、yyはzip形式)zzはmovieフォルダ以外の動画ファイル /// </summary> /// <param name="myTargetFile"></param> /// <returns></returns> private string GetMovieCount(TargetFile myTargetFile) { int NormalCount = 0, BlueCount = 0; string DisplayCount = ""; string[] files = Directory.GetFiles(myTargetFile.DirInfo.FullName, "*", SearchOption.AllDirectories); Regex regex = new Regex(MovieFileContents.REGEX_MOVIE_EXTENTION); List<string> listFiles = new List<string>(); List<string> listExt = new List<string>(); string WorkExtension = ""; foreach (var file in files) { FileInfo fileinfo = new FileInfo(file.ToString()); if (regex.IsMatch(fileinfo.Name.ToLower())) { if (WorkExtension.IndexOf(fileinfo.Extension.Replace(".", "")) < 0) { if (WorkExtension.Length > 0) WorkExtension += ","; WorkExtension += fileinfo.Extension.Replace(".", ""); } if (SiteName.Equals("舞ワイフ")) { if (Regex.Match(fileinfo.Name, "^w.*").Success) NormalCount++; if (Regex.Match(fileinfo.Name, "^Bw.*").Success) BlueCount++; } else NormalCount++; if (MovieNewDate < fileinfo.LastWriteTime) MovieNewDate = fileinfo.LastWriteTime; } } Extension = WorkExtension.ToUpper(); if (BlueCount > 0) DisplayCount = NormalCount + "/" + BlueCount; else DisplayCount = NormalCount.ToString(); //if (!Directory.Exists(MovieSearchPath)) // return ""; return DisplayCount; }
public MovieSiteContents(string mySiteName, TargetFile myFile) { SiteName = mySiteName; Name = myFile.Name; string strDir = Regex.Match(myFile.DirInfo.Parent.FullName, ".*" + mySiteName + "\\\\(?<abc>.*)").Groups["abc"].Value; ParentPath = strDir; //ParentPath = myFile.DirInfo.Parent.Name.Replace(mySiteName, ""); MovieCount = myFile.strMovieCount; PhotoCount = myFile.PhotoCount.ToString(); Extension = ""; targetfile = myFile; }
public List<TargetFile> GetDirectorysInfo(string myPath) { if (myPath == null) return null; dirinfoMain = new DirectoryInfo(myPath); listTargetFiles = new List<TargetFile>(); string[] arrTargetDir = null; try { arrTargetDir = Directory.GetDirectories(myPath, "*", SearchOption.TopDirectoryOnly); } catch (ArgumentException) { return null; } catch (DirectoryNotFoundException) { //Directory.CreateDirectory(myPath); return null; } catch (IOException) { // デバイスの準備が出来ていません return null; } for (int idxArr = 0; idxArr < arrTargetDir.Length; idxArr++) { DirectoryInfo dir = new DirectoryInfo(arrTargetDir[idxArr]); TargetFile file = new TargetFile(); file.DirInfo = dir; listTargetFiles.Add(file); } Debug.Print("GetDirectorysInfo 件数 [" + listTargetFiles.Count + "]"); return listTargetFiles; }
/// <summary> /// 動画の件数をカウントする、通常はxx(zz)件だが舞ワイフはxx(yy)/xx(yy)の形式でリターン(xxはwmvファイル、yyはzip形式)zzはmovieフォルダ以外の動画ファイル /// </summary> /// <param name="myTargetFile"></param> /// <returns></returns> private string GetMovieCount(TargetFile myTargetFile) { int NormalCount = 0, BlueCount = 0; int NormalZipCount = 0, BlueZipCount = 0; string DisplayCount = ""; string MovieSearchPath = null; if (setting == null) MovieSearchPath = myTargetFile.DirInfo.FullName; else MovieSearchPath = Path.Combine(myTargetFile.DirInfo.FullName, setting.MakeListMovieFolder); //if (!Directory.Exists(MovieSearchPath)) // return ""; if (setting.SiteName.Equals("舞ワイフ")) { if (Directory.Exists(MovieSearchPath)) { NormalCount = Directory.GetFiles(MovieSearchPath, "w*" + setting.MakeListExt, SearchOption.TopDirectoryOnly).Count(); BlueCount = Directory.GetFiles(MovieSearchPath, "Bw*" + setting.MakeListExt, SearchOption.TopDirectoryOnly).Count(); NormalZipCount = Directory.GetFiles(MovieSearchPath, "w*zip", SearchOption.TopDirectoryOnly).Count(); BlueZipCount = Directory.GetFiles(MovieSearchPath, "Bw*zip", SearchOption.TopDirectoryOnly).Count(); } if (NormalCount == 0 && BlueCount == 0 && NormalZipCount == 0 && BlueZipCount == 0) DisplayCount = ""; else { StringBuilder sb = new StringBuilder(); sb.Append(NormalCount); if (NormalZipCount > 0) sb.Append("(" + NormalZipCount + ")/"); else sb.Append("/"); sb.Append(BlueCount); if (BlueZipCount > 0) sb.Append("(" + BlueZipCount + ")"); DisplayCount = sb.ToString(); } } else { int TopCount = 0, MovieFolderCount = 0; TopCount = Directory.GetFiles(myTargetFile.DirInfo.FullName, "*" + setting.MakeListExt, SearchOption.TopDirectoryOnly).Count(); if (Directory.Exists(MovieSearchPath)) MovieFolderCount = Directory.GetFiles(MovieSearchPath, "*" + setting.MakeListExt, SearchOption.TopDirectoryOnly).Count(); StringBuilder sb = new StringBuilder(); if (MovieFolderCount > 0) sb.Append(MovieFolderCount); if (TopCount > 0) { if (MovieFolderCount > 0) sb.Append("/("); else sb.Append("("); sb.Append(TopCount); sb.Append(")"); } DisplayCount = sb.ToString(); } return DisplayCount; }
private string GetPlayListFile(TargetFile myFile) { string[] arrSearchFilePattern = { "_MP4", "_DIRNAME*" }; foreach (string FilePattern in arrSearchFilePattern) { string SearchFilename = ""; if (FilePattern.IndexOf("DIRNAME") >= 0) SearchFilename = FilePattern.Replace("DIRNAME", myFile.DirInfo.Name).Replace("MP4", "") + "." + setting.MakeListKind; else SearchFilename = FilePattern + "." + setting.MakeListKind; string[] matchfile = Directory.GetFiles(myFile.DirInfo.FullName, SearchFilename, SearchOption.TopDirectoryOnly); if (matchfile.Count() > 0) return matchfile[0]; } return ""; }