// Constructor public Document(Craft craft, string fullPath) { FolderPath = craft.Folder; FullPath = fullPath; FileName = FullPath.Replace(craft.Folder, "").TrimStart('\\'); ShortFileName = FileName.Replace(".pdf", ""); ListDisplayName = $"{craft.Name}/{ShortFileName}"; Craft = craft; PrettyCraftName = ("(" + Craft.Name + ")").PadRight(16, ' '); Selected = false; LastModified = System.IO.File.GetLastWriteTime(FullPath).ToString(); // LastModified is from StackOverflow -- does it always work? // https://stackoverflow.com/questions/3360324/check-last-modified-date-of-file-in-c-sharp }
// Import documents from a Craft's folder public static List <Document> Import(Craft craft) { var tmpDocs = new List <Document>(); string tmpPath = craft.Folder; if (System.IO.Directory.Exists(tmpPath)) { foreach (string f in System.IO.Directory.GetFiles(tmpPath)) { tmpDocs.Add(new Document(craft, f)); } } else { Misc.Globals.ShowMsg($"Craft:\n{craft.Name}\n\nFolder:\n{craft.Folder}\n\nMessage:\nFolder not found. No documents to import.", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } return(tmpDocs); }