public void CopyFromNoBarcode(VoucherItem itemNoBarcode) { Debug.Assert(itemNoBarcode != null); //Debug.Assert(!itemNoBarcode.HasBarcode); //Debug.Assert(HasBarcode); //JobID = itemNoBarcode.JobID; //CountryID = item.CountryID; //RetailerID = item.RetailerID; //VoucherID = item.VoucherID; //Barcode = item.Barcode; //Don't copy site code //SiteCode = item.SiteCode; State = itemNoBarcode.State; HasBarcode = true; //Don't delete SessionID //SessionID = item.SessionID; FileInfoList.Clear(); FileInfoList.AddRange(itemNoBarcode.FileInfoList); Thumbnail = itemNoBarcode.Thumbnail; Selected = itemNoBarcode.Selected; Message = itemNoBarcode.Message; }
public void CopyFromWithBarcode(VoucherItem itemHasBarcode) { Debug.Assert(itemHasBarcode != null); Debug.Assert(itemHasBarcode.HasBarcode); JobID = itemHasBarcode.JobID; CountryID = itemHasBarcode.CountryID; RetailerID = itemHasBarcode.RetailerID; VoucherID = itemHasBarcode.VoucherID; Barcode = itemHasBarcode.Barcode; //Don't copy site code SiteCode = itemHasBarcode.SiteCode ?? SiteCode; State = itemHasBarcode.State; HasBarcode = itemHasBarcode.HasBarcode; //Don't delete SessionID //SessionID = item.SessionID; FileInfoList.Clear(); FileInfoList.AddRange(itemHasBarcode.FileInfoList); Thumbnail = itemHasBarcode.Thumbnail; Selected = itemHasBarcode.Selected; Message = itemHasBarcode.Message; }
private bool CreateFileList(List <string> files) { Log.Logger.Information("Creating file and folder list ..."); // Trim quotes from input paths files = files.Select(file => file.Trim('"')).ToList(); // Process all entries foreach (string fileOrFolder in files) { // File or a directory FileAttributes fileAttributes; try { fileAttributes = File.GetAttributes(fileOrFolder); } catch (Exception e) when(Log.Logger.LogAndHandle(e, MethodBase.GetCurrentMethod()?.Name)) { return(false); } if (fileAttributes.HasFlag(FileAttributes.Directory)) { // Add this directory DirectoryInfo dirInfo = new(fileOrFolder); DirectoryInfoList.Add(dirInfo); FolderList.Add(fileOrFolder); // Create the file list from the directory Log.Logger.Information("Getting files and folders from {Directory} ...", dirInfo.FullName); if (!FileEx.EnumerateDirectory(fileOrFolder, out List <FileInfo> fileInfoList, out List <DirectoryInfo> directoryInfoList)) { Log.Logger.Error("Failed to enumerate directory {Directory}", fileOrFolder); return(false); } FileInfoList.AddRange(fileInfoList); DirectoryInfoList.AddRange(directoryInfoList); } else { // Add this file FileInfoList.Add(new FileInfo(fileOrFolder)); } } // Report Log.Logger.Information("Discovered {DirectoryInfoListCount} directories and {FileInfoListCount} files", DirectoryInfoList.Count, FileInfoList.Count); return(true); }
/// <param name="detailList"></param> /// <param name="currentDir">The current directory relative to the base of the archive, for file naming</param> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <param name="simpleList"></param> protected void findFiles(string pattern, bool recursive, List <string> simpleList, FileInfoList detailList, string currentDir) { if (currentDir == "") { currentDir = this._zipDir; } Load(); if (pattern.Contains("*")) { pattern = pattern.Replace(".", @"\.").Replace("*", ".*") + "$"; } var ex = new Regex(pattern); var files = from entry in _zipStream.Entries where ex.IsMatch(entry.FileName) select new FileInfo { Archive = this, Filename = entry.FileName, Basename = Path.GetFileName(entry.FileName), Path = Path.GetDirectoryName(entry.FileName) + Path.DirectorySeparatorChar, CompressedSize = entry.CompressedSize, UncompressedSize = entry.UncompressedSize, ModifiedTime = entry.CreationTime }; if (detailList != null) { detailList.AddRange(files); } if (simpleList != null) { simpleList.AddRange(from file in files select file.Filename); } }
private void LoadFiles(string Filename) { LoadTree(Filename); DirectoryInfo di = (new FileInfo(Filename)).Directory; if (olddi == null || (olddi != null && !di.FullName.Equals(olddi.FullName))) { olddi = di; FileInfoList.Clear(); List <PhotoFileInfo> _FileInfoList = new List <PhotoFileInfo>(); foreach (FileInfo fi in di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly)) { _FileInfoList.Add(new PhotoFileInfo(fi)); } FileInfoList.AddRange(_FileInfoList.OrderBy(x => x.Name)); this.Invoke((MethodInvoker) delegate { dGVFiles.DataSource = null; dGVFiles.DataSource = FileInfoList; dGVFiles.Refresh(); }); } }