// 拡張メソッド public static string Text(this FromDistribute value) { string[] values = { "ファイル名", "作成日時", "撮影日時" }; return(values[(int)value]); }
public static void SetFileDataSet(Action <int> action, FromDistribute from, DataTable dt, params string[] files) { switch (from) { case FromDistribute.FileName: for (int i = 0; i < files.Length; i++) { string fileName = Path.GetFileNameWithoutExtension(files[i]); string afterFileName = string.Empty; if (TryParthToDateTime(fileName, out afterFileName)) { dt.Rows.Add(files[i], Path.Combine(Path.GetDirectoryName(files[i]), string.Concat(afterFileName, Path.GetExtension(files[i])))); } else { dt.Rows.Add(files[i]); } action.Invoke(i + 1); } break; case FromDistribute.CreateDate: for (int i = 0; i < files.Length; i++) { string afterFileName = string.Empty; if (TryParthFromCreateDate(files[i], out afterFileName)) { dt.Rows.Add(files[i], Path.Combine(Path.GetDirectoryName(files[i]), string.Concat(afterFileName, Path.GetExtension(files[i])))); } else { dt.Rows.Add(files[i]); } action.Invoke(i + 1); } break; case FromDistribute.ShotDate: for (int i = 0; i < files.Length; i++) { string afterFileName = string.Empty; if (TryParthFromShotDate(files[i], out afterFileName)) { dt.Rows.Add(files[i], Path.Combine(Path.GetDirectoryName(files[i]), string.Concat(afterFileName, Path.GetExtension(files[i])))); } else { dt.Rows.Add(files[i]); } action.Invoke(i + 1); } break; } }