18using System.Collections.Generic;
24using System.Threading.Tasks;
35 public class GPALFile :
IGPALFile, IGPALFileInternal
42 GPALFileSettings IGPALFileInternal.FileSettings {
get;
set; }
58 ((IGPALFileInternal)
this).FileSettings =
new GPALFileSettings();
59 ((IGPALFileInternal)
this).FileDictionary =
new List<Dictionary<object, dynamic>>();
67 internal GPALFile(
string fileName)
69 ((IGPALFileInternal)
this).FileSettings =
new GPALFileSettings();
70 ((IGPALFileInternal)
this).FileSettings.Filenames.Add(fileName);
71 ((IGPALFileInternal)
this).FileDictionary =
new List<Dictionary<object, dynamic>>();
73 #region <Fluent Interface>
82 ((IGPALFileInternal)
this).FileSettings.OverwriteFile.Add(overwriteFile);
94 ((IGPALFileInternal)
this).FileSettings.FileSortOrder = fileSortOrder;
106 ((IGPALFileInternal)
this).FileSettings.NextFilePattern = nextFilePattern;
116 ((IGPALFileInternal)
this).FileSettings.Delimiter.Add(delimiter);
127 ((IGPALFileInternal)
this).FileSettings.FieldsEnclosedInQuotes.Add(fieldsInQuotes);
137 ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Add(firstLineIsColumnNames);
147 ((IGPALFileInternal)
this).FileSettings.IgnoreFirstLineColumnNames.Add(ignoreFirstLine);
158 ((IGPALFileInternal)
this).FileSettings.UseOneHeaderForAllFiles = useHeaderForAllFiles;
182 ((IGPALFileInternal)
this).FileSettings.Browser = browser;
204 fileName = Environment.ExpandEnvironmentVariables(fileName);
207 if (
true ==
FileHelper.IsWebAddress(fileName))
210 string name = Path.GetFileName(
new Uri(fileName).LocalPath);
211 string localPath = Path.Combine(
GPAL.TempDirectory(),
true ==
string.IsNullOrWhiteSpace(name) ?
"download" : name);
213 ((IGPALFileInternal)
this).FileSettings.SourceUrl = fileName;
220 FileHelper.FetchOrDownloadInTab(fileName, localPath, browser);
222 FileHelper.DownloadToFile(
null, localPath, fileName);
224 fileName = localPath;
227 if (
true == fileName.Contains(
'*') ||
true == fileName.Contains(
'?'))
229 string directory = Path.GetDirectoryName(fileName);
230 string filenamePart = Path.GetFileName(fileName);
231 string[] matches = Directory.GetFiles(
false ==
string.IsNullOrEmpty(directory) ? directory :
@".\", filenamePart);
233 if (0 == matches.Length)
235 GPAL.
PublishSimpleEvent(Enums.GPALEventType.WARNING, $
"No files matched the wildcard pattern [{fileName}].",
this, Enums.GPALObjectType.GPALFile);
239 IEnumerable<string> sortedMatches;
241 switch (((IGPALFileInternal)
this).FileSettings.FileSortOrder)
243 case Enums.FileSortOrder.NameDescending:
244 sortedMatches = matches.OrderByDescending(m => m, StringComparer.OrdinalIgnoreCase);
246 case Enums.FileSortOrder.NaturalAscending:
247 sortedMatches = matches.OrderBy(m => m, NaturalFilenameComparer.Instance);
249 case Enums.FileSortOrder.NaturalDescending:
250 sortedMatches = matches.OrderByDescending(m => m, NaturalFilenameComparer.Instance);
252 case Enums.FileSortOrder.DateModifiedAscending:
253 sortedMatches = matches.OrderBy(m => File.GetLastWriteTimeUtc(m));
255 case Enums.FileSortOrder.DateModifiedDescending:
256 sortedMatches = matches.OrderByDescending(m => File.GetLastWriteTimeUtc(m));
258 case Enums.FileSortOrder.DateCreatedAscending:
259 sortedMatches = matches.OrderBy(m => File.GetCreationTimeUtc(m));
261 case Enums.FileSortOrder.DateCreatedDescending:
262 sortedMatches = matches.OrderByDescending(m => File.GetCreationTimeUtc(m));
264 case Enums.FileSortOrder.NameAscending:
266 sortedMatches = matches.OrderBy(m => m, StringComparer.OrdinalIgnoreCase);
270 foreach (
string match
in sortedMatches)
272 ((IGPALFileInternal)
this).FileSettings.Filenames.Add(match);
273 ((IGPALFileInternal)
this).FileSettings.FileCount++;
279 ((IGPALFileInternal)
this).FileSettings.Filenames.Add(fileName);
280 ((IGPALFileInternal)
this).FileSettings.FileCount++;
294 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.ColumnList.Count())
295 ((IGPALFileInternal)
this).FileSettings.ColumnList.AddRow(
new List<string>());
297 ((IGPALFileInternal)
this).FileSettings.ColumnList[((IGPALFileInternal)
this).FileSettings.FileCount - 1].Add(columnName);
299 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Count)
300 ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Add(
true);
313 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.ColumnList.Count())
314 ((IGPALFileInternal)
this).FileSettings.ColumnList.AddRow(
new List<string>());
318 string oldColumns =
string.Join(
", ", ((IGPALFileInternal)
this).FileSettings.ColumnList[((IGPALFileInternal)
this).FileSettings.FileCount - 1]);
319 GPAL.
PublishSimpleEvent(Enums.GPALEventType.WARNING, $
"Overwriting existing column names [{oldColumns}] with new names [{columnNames}]");
320 ((IGPALFileInternal)
this).FileSettings.ColumnList.Clear();
323 foreach (
string columnName
in columnNames.Split(
','))
324 ((IGPALFileInternal)
this).FileSettings.ColumnList[((IGPALFileInternal)
this).FileSettings.FileCount - 1].Add(columnName.Trim());
328 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Count)
329 ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Add(
true);
344 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.ColumnList.Count())
345 ((IGPALFileInternal)
this).FileSettings.ColumnList.AddRow(
new List<string>());
348 if (0 < ((IGPALFileInternal)
this).FileSettings.Delimiter.Count &&
true == ((IGPALFileInternal)
this).FileSettings.Delimiter[((IGPALFileInternal)
this).FileSettings.FileCount].HasValue)
349 delim = ((IGPALFileInternal)
this).FileSettings.Delimiter[((IGPALFileInternal)
this).FileSettings.FileCount].Value;
353 foreach (
string columnName
in columnNames)
354 ((IGPALFileInternal)
this).FileSettings.ColumnList[((IGPALFileInternal)
this).FileSettings.FileCount - 1].Add(columnName);
356 if (((IGPALFileInternal)
this).FileSettings.FileCount > ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Count)
357 ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames.Add(
true);
361 #endregion <Fluent Interface>
363 #region <Getters/Setters>
372 if (0 < ((IGPALFileInternal)
this).FileSettings.FileCount)
374 ((IGPALFileInternal)
this).FileSettings.NextFileCount = 0;
375 return ((IGPALFileInternal)
this).FileSettings.Filenames[0];
389 if (0 < ((IGPALFileInternal)
this).FileSettings.FileCount)
391 ((IGPALFileInternal)
this).FileSettings.NextFileCount = ((IGPALFileInternal)
this).FileSettings.Filenames.Count - 1;
392 return ((IGPALFileInternal)
this).FileSettings.Filenames[((IGPALFileInternal)
this).FileSettings.Filenames.Count - 1];
410 string fullPath =
null;
411 string newFilename =
null;
412 Enums.NextFilePattern nextPattern = ((IGPALFileInternal)
this).FileSettings.NextFilePattern;
413 int patternCounter = ((IGPALFileInternal)
this).FileSettings.NextPatternCounter;
415 if (0 == ((IGPALFileInternal)
this).FileSettings.OverwriteFile.Count)
417 if (((IGPALFileInternal)
this).FileSettings.NextFileCount < ((IGPALFileInternal)
this).FileSettings.FileCount)
419 fullPath =
FileHelper.CleanUpFileDestination(((IGPALFileInternal)
this).FileSettings.Filenames[((IGPALFileInternal)
this).FileSettings.NextFileCount], out newFilename, DeleteFileBeforeDownload:
false, nextPattern, ref patternCounter);
420 ((IGPALFileInternal)
this).FileSettings.NextPatternCounter = patternCounter;
423 ((IGPALFileInternal)
this).FileSettings.ReturnFilenames.Add(fullPath);
424 ((IGPALFileInternal)
this).FileSettings.NextFileCount++;
429 fullPath =
FileHelper.CleanUpFileDestination(((IGPALFileInternal)
this).FileSettings.Filenames[((IGPALFileInternal)
this).FileSettings.NextFileCount-1], out newFilename, DeleteFileBeforeDownload:
false, nextPattern, ref patternCounter);
430 ((IGPALFileInternal)
this).FileSettings.NextPatternCounter = patternCounter;
431 ((IGPALFileInternal)
this).FileSettings.ReturnFilenames.Add(fullPath);
437 else if (((IGPALFileInternal)
this).FileSettings.NextFileCount < ((IGPALFileInternal)
this).FileSettings.OverwriteFile.Count)
439 if (
true == ((IGPALFileInternal)
this).FileSettings.OverwriteFile[((IGPALFileInternal)
this).FileSettings.NextFileCount])
441 fullPath =
FileHelper.CleanUpFileDestination(((IGPALFileInternal)
this).FileSettings.Filenames[((IGPALFileInternal)
this).FileSettings.NextFileCount++], out newFilename, DeleteFileBeforeDownload:
true);
442 ((IGPALFileInternal)
this).FileSettings.ReturnFilenames.Add(fullPath);
446 else if (((IGPALFileInternal)
this).FileSettings.NextFileCount < ((IGPALFileInternal)
this).FileSettings.FileCount)
448 fullPath =
FileHelper.CleanUpFileDestination(((IGPALFileInternal)
this).FileSettings.Filenames[((IGPALFileInternal)
this).FileSettings.NextFileCount], out newFilename, DeleteFileBeforeDownload:
false, nextPattern, ref patternCounter);
449 ((IGPALFileInternal)
this).FileSettings.NextPatternCounter = patternCounter;
452 ((IGPALFileInternal)
this).FileSettings.ReturnFilenames.Add(fullPath);
453 ((IGPALFileInternal)
this).FileSettings.NextFileCount++;
461 int patternIdx = Math.Min(((IGPALFileInternal)
this).FileSettings.NextFileCount, ((IGPALFileInternal)
this).FileSettings.FileCount - 1);
463 fullPath =
FileHelper.CleanUpFileDestination(((IGPALFileInternal)
this).FileSettings.Filenames[patternIdx], out newFilename, DeleteFileBeforeDownload:
false, nextPattern, ref patternCounter);
464 ((IGPALFileInternal)
this).FileSettings.NextPatternCounter = patternCounter;
465 ((IGPALFileInternal)
this).FileSettings.ReturnFilenames.Add(fullPath);
477 return ((IGPALFileInternal)
this).FileSettings.Filenames[0];
488 return ((IGPALFileInternal)
this).FileSettings.Filenames.Select(filename => Path.GetDirectoryName(filename)).ToList();
498 return ((IGPALFileInternal)
this).FileSettings.Filenames.Select(filename => Path.GetFileName(filename)).ToList();
509 return Path.GetDirectoryName(((IGPALFileInternal)
this).FileSettings.Filenames[0]);
529 return Path.GetFileName(((IGPALFileInternal)
this).FileSettings.Filenames[0]);
539 return ((IGPALFileInternal)
this).FileSettings.Filenames;
549 return ((IGPALFileInternal)
this).FileSettings.ReturnFilenames;
561 return ((IGPALFileInternal)
this).FileSettings.SourceUrl;
569 List<IGPALGrid<string>> IGPALFileInternal.TokenList
573 return ((IGPALFileInternal)
this).FileSettings.TokenList;
577 ((IGPALFileInternal)
this).FileSettings.TokenList = value;
583 List<string> IGPALFileInternal.FileData
587 return ((IGPALFileInternal)
this).FileSettings.FileData;
591 ((IGPALFileInternal)
this).FileSettings.FileData = value;
597 List<char?> IGPALFileInternal.Delimiter
601 return ((IGPALFileInternal)
this).FileSettings.Delimiter;
605 ((IGPALFileInternal)
this).FileSettings.Delimiter = value;
612 List<bool> IGPALFileInternal.FieldsEnclosedInQuotes
616 return ((IGPALFileInternal)
this).FileSettings.FieldsEnclosedInQuotes;
620 ((IGPALFileInternal)
this).FileSettings.FieldsEnclosedInQuotes = value;
627 List<bool> IGPALFileInternal.FirstLineIsColumnNames
631 return ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames;
635 ((IGPALFileInternal)
this).FileSettings.FirstLineIsColumnNames = value;
642 List<bool> IGPALFileInternal.IgnoreFirstLineColumnNames
646 return ((IGPALFileInternal)
this).FileSettings.IgnoreFirstLineColumnNames;
650 ((IGPALFileInternal)
this).FileSettings.IgnoreFirstLineColumnNames = value;
657 bool IGPALFileInternal.UseOneHeaderForAllFiles
661 return ((IGPALFileInternal)
this).FileSettings.UseOneHeaderForAllFiles;
665 ((IGPALFileInternal)
this).FileSettings.UseOneHeaderForAllFiles = value;
671 List<Dictionary<object, dynamic>> IGPALFileInternal.FileDictionary
675 return ((IGPALFileInternal)
this).FileSettings.FileDictionary;
679 ((IGPALFileInternal)
this).FileSettings.FileDictionary = value;
685 List<IGPALGrid<string>> IGPALFileInternal.FileGrid
689 return ((IGPALFileInternal)
this).FileSettings.FileGrid;
693 ((IGPALFileInternal)
this).FileSettings.FileGrid = value;
700 bool IGPALFileInternal.AlreadyTokenized
704 return ((IGPALFileInternal)
this).FileSettings.AlreadyTokenized;
709 ((IGPALFileInternal)
this).FileSettings.AlreadyTokenized = value;
719 #endregion <Getters/Setters>
731 string myDestination = destination;
732 bool isDir = IsDirectoryOnly(destination);
734 foreach (
string filename
in ((IGPALFileInternal)
this).FileSettings.Filenames)
738 string directory = Path.GetDirectoryName(filename);
739 string filenamepart = Path.GetFileName(filename);
741 foreach (
string filename2
in Directory.GetFiles(
false ==
string.IsNullOrEmpty(directory) ? directory :
@".\", filenamepart))
744 myDestination = Path.Combine(destination, Path.GetFileName(filename2));
745 File.Copy(filename2, myDestination);
746 GPAL.
PublishSimpleEvent(Enums.GPALEventType.INFO, $
"[{filename2}] copied to [{destination}].",
this, Enums.GPALObjectType.GPALFile);
751 GPAL.
PublishSimpleEvent(Enums.GPALEventType.EXCEPTION, $
"Unable to copy [{filename}] to [{destination}].",
this, Enums.GPALObjectType.GPALFile, ex);
765 string myDestination = destination;
766 bool isDir = IsDirectoryOnly(destination);
768 foreach (
string filename
in ((IGPALFileInternal)
this).FileSettings.Filenames)
772 string directory = Path.GetDirectoryName(filename);
773 string filenamepart = Path.GetFileName(filename);
775 foreach (
string filename2
in Directory.GetFiles(
false ==
string.IsNullOrEmpty(directory) ? directory :
@".\", filenamepart))
778 myDestination = Path.Combine(destination, Path.GetFileName(filename2));
779 File.Move(filename2, myDestination);
780 GPAL.
PublishSimpleEvent(Enums.GPALEventType.INFO, $
"[{filename2}] moved to [{destination}].",
this, Enums.GPALObjectType.GPALFile);
785 GPAL.
PublishSimpleEvent(Enums.GPALEventType.EXCEPTION, $
"Unable to move [{filename}] to [{destination}].",
this, Enums.GPALObjectType.GPALFile, ex);
797 string myDestination = destination;
798 bool isDir = IsDirectoryOnly(destination);
803 foreach (
string filename
in Directory.GetFiles(destination))
805 myDestination = Path.Combine(destination, filename);
806 File.Delete(Path.Combine(myDestination, filename));
807 GPAL.
PublishSimpleEvent(Enums.GPALEventType.INFO, $
"[{myDestination}] deleted.",
this, Enums.GPALObjectType.GPALFile);
811 File.Delete(myDestination);
812 GPAL.
PublishSimpleEvent(Enums.GPALEventType.INFO, $
"[{myDestination}] deleted.",
this, Enums.GPALObjectType.GPALFile);
817 GPAL.
PublishSimpleEvent(Enums.GPALEventType.EXCEPTION, $
"Unable to delete[{myDestination}].",
this, Enums.GPALObjectType.GPALFile, ex);
826 foreach (
string filename
in ((IGPALFileInternal)
this).FileSettings.Filenames)
830 File.Delete(filename);
831 GPAL.
PublishSimpleEvent(Enums.GPALEventType.INFO, $
"[{filename}] deleted.",
this, Enums.GPALObjectType.GPALFile);
835 GPAL.
PublishSimpleEvent(Enums.GPALEventType.EXCEPTION, $
"Unable to delete [{filename}].",
this, Enums.GPALObjectType.GPALFile, ex);
848 internal static bool IsDirectoryOnly(
string path)
855 bool isDirectory =
true == path.EndsWith(Path.DirectorySeparatorChar.ToString())
856 ||
true == path.EndsWith(Path.AltDirectorySeparatorChar.ToString())
857 ||
true == Directory.Exists(path)
858 ||
false == Path.HasExtension(path);
862 string directoryToCreate =
true == isDirectory ? path : Path.GetDirectoryName(path);
864 if (
false ==
string.IsNullOrEmpty(directoryToCreate) &&
false == Directory.Exists(directoryToCreate))
866 Directory.CreateDirectory(directoryToCreate);
878 internal GPALFile Clone()
880 GPALFile clone =
new GPALFile();
881 IGPALFileInternal cloneInternal = (IGPALFileInternal)clone;
882 IGPALFileInternal thisInternal = (IGPALFileInternal)
this;
885 cloneInternal.FileSettings =
new GPALFileSettings
887 Filenames =
new List<string>(thisInternal.FileSettings.Filenames),
888 FileCount = thisInternal.FileSettings.FileCount,
889 NextFileCount = thisInternal.FileSettings.NextFileCount,
890 Delimiter =
new List<char?>(thisInternal.FileSettings.Delimiter),
891 FieldsEnclosedInQuotes =
new List<bool>(thisInternal.FileSettings.FieldsEnclosedInQuotes),
892 FirstLineIsColumnNames =
new List<bool>(thisInternal.FileSettings.FirstLineIsColumnNames),
893 IgnoreFirstLineColumnNames =
new List<bool>(thisInternal.FileSettings.IgnoreFirstLineColumnNames),
894 UseOneHeaderForAllFiles = thisInternal.FileSettings.UseOneHeaderForAllFiles,
895 TokenList = thisInternal.FileSettings.TokenList !=
null ?
new List<IGPALGrid<string>>(thisInternal.FileSettings.TokenList) : null,
896 FileData = thisInternal.FileSettings.FileData != null ? new List<string>(thisInternal.FileSettings.FileData) : null,
897 FileDictionary = thisInternal.FileSettings.FileDictionary != null ? new List<Dictionary<object, dynamic>>(thisInternal.FileSettings.FileDictionary) : null,
898 FileGrid = thisInternal.FileSettings.FileGrid != null ? new List<IGPALGrid<string>>(thisInternal.FileSettings.FileGrid) : null,
899 AlreadyTokenized = thisInternal.FileSettings.AlreadyTokenized
903 cloneInternal.FileDictionary = thisInternal.FileDictionary !=
null ?
new List<Dictionary<object, dynamic>>(thisInternal.FileDictionary) :
null;
908 #region Implicit Converter
915 public static implicit
operator string(GPALFile url) => url.
Filename;
925 public static implicit
operator GPALFile(
string fileName)
927 var file =
new GPALFile();
929 if (
string.IsNullOrWhiteSpace(fileName))
933 "Implicit conversion received null or whitespace filename - " +
934 "creating placeholder GPALFile with no real filename.",
936 GPALObjectType.GPALFile
939 file.WithFileName(
"Placeholder_Empty_" + DateTime.UtcNow.Ticks);
943 string trimmed = fileName.Trim();
946 file.WithFileName(trimmed);
949 string shortName = trimmed.Length > 48
950 ? trimmed.Substring(0, 45) +
"..."
955 $
"Implicit GPALFile created from [{shortName}]."
960 #endregion Implicit Converter
967 internal class NaturalFilenameComparer : IComparer<string>
969 public static readonly NaturalFilenameComparer Instance =
new NaturalFilenameComparer();
971 public int Compare(
string x,
string y)
973 IEnumerable<string> partsX = SplitIntoParts(x);
974 IEnumerable<string> partsY = SplitIntoParts(y);
976 using (var enumX = partsX.GetEnumerator())
977 using (var enumY = partsY.GetEnumerator())
981 bool hasX = enumX.MoveNext();
982 bool hasY = enumY.MoveNext();
984 if (
false == hasX &&
false == hasY)
991 string partX = enumX.Current;
992 string partY = enumY.Current;
994 bool isNumericX =
char.IsDigit(partX[0]);
995 bool isNumericY =
char.IsDigit(partY[0]);
999 if (
true == isNumericX &&
true == isNumericY)
1002 BigInteger numX = BigInteger.Parse(partX);
1003 BigInteger numY = BigInteger.Parse(partY);
1004 comparison = numX.CompareTo(numY);
1008 comparison =
string.Compare(partX, partY, StringComparison.OrdinalIgnoreCase);
1011 if (0 != comparison)
1017 private static IEnumerable<string> SplitIntoParts(
string value)
1021 while (index < value.Length)
1023 bool isDigit =
char.IsDigit(value[index]);
1026 while (index < value.Length &&
char.IsDigit(value[index]) == isDigit)
1029 yield
return value.Substring(start, index - start);
File-side plumbing behind the fluent chain: writing a unit of work's data out in a delimited format,...
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
IAllowFileSettings WithColumnsEnclosedInQuotes(bool fieldsInQuotes)
Specifies whether each field (column value) in the file is enclosed in quotes. Applies to flat files ...
void CopyTo(string destination)
Copies each file in Filenames to destination . If destination is a directory (per IsDirectoryOnly(st...
void MoveTo(string destination)
Moves each file in Filenames to destination . If destination is a directory (per IsDirectoryOnly(str...
string DirectoryPart
The folder of the first filename, since most files are singular. Same shortcut Filename is to Filenam...
string First
Returns the first filename in Filenames and resets the Next cursor so that a subsequent call to Next ...
IAllowFileSettings WithNextFilePattern(Enums.NextFilePattern nextFilePattern=Enums.NextFilePattern.CounterPadded)
Sets how Next builds a new, unique filename when it needs one (the target file already exists,...
IAllowFileSettings WithColumnName(string columnName)
.WithColumnName adds columns to the same 'most recent' column list. NOTE: .WithColumnNameS allows You...
List< string > DirectoryParts
The folder of every filename, in the same order as Filenames, so a wildcard that matched across folde...
void Delete()
Deletes every file in Filenames. Errors are reported via GPAL.PublishSimpleEvent rather than thrown.
string Last
Returns the last filename in Filenames and positions the Next cursor at that filename so that a subse...
List< string > ReturnFilenames
Get the list of filenames saved to (returned).
IAllowFileSettings WithFileName(string fileName)
The filename to load input tokens from. An http or https address is fetched to a local file in the w...
IAllowFileSettings WithColumnNames(string columnNames)
Add column names to the column name list using the .WithDelimiter to separate names....
List< string > FileParts
The name and extension of every filename, without its folder, in the same order as Filenames.
GPALFile Next
Advances an internal cursor and returns the next filename to use. If there is exactly one file and Wi...
int Count
The number of filenames in Filenames.
IAllowFileSettings WithOverwriteFile(bool overwriteFile=false)
Sets whether the destination file(s) should be overwritten or a new filename should be generated (use...
IAllowFileSettings WithFileSortOrder(Enums.FileSortOrder fileSortOrder)
Sets the order in which files matched by a wildcard pattern (e.g. *.csv) passed to WithFileName(strin...
IAllowFileSettings WithDelimiter(char delimiter)
THe character delimiting each token in the row (columns).
IAllowFileSettings WithIgnoreFirstLineColumnNames(bool ignoreFirstLine=true)
Specifies that the first line of the file (a column header row) should be ignored/skipped when readin...
void Delete(string destination)
Deletes the file at destination , or if it is a directory (per IsDirectoryOnly(string)),...
IAllowFileSettings WithBrowser(Browser.IBrowser browser)
The browser whose session can reach a url that our own connection cannot, for a file behind a login o...
string FilePart
The name and extension of the first filename, without its folder. Useful for putting the same name in...
GPALFile ToGPALObject()
Returns this GPALFile instance, allowing it to be passed where a generic GPAL object is expected.
List< string > Filenames
Get the list of filenames.
string SourceUrl
The url this file was fetched from, when .WithFileName was given one. Null for a file that was alread...
string Filename
We have only one file, accessing it.
IAllowFileSettings WithUseSameColumnNamesForAllFiles(bool useHeaderForAllFiles)
Specifies that a single column name list has been defined and should be reused for every file in the ...
IAllowFileSettings WithColumnNames(string[] columnNames)
Add column names to the column name list using the .WithDelimiter to separate names....
IAllowFileSettings WithFirstLineIsColumnNames(bool firstLineIsColumnNames)
Specifies that the first line of the file contains column header names.
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
static void PublishSimpleEvent(GPALEventType gPALEventType, string msg, dynamic gPALObject=null, Enums.GPALObjectType gPALObjectType=GPALObjectType.None, Exception ex=null)
Publish a message to either the information channel or exception channel (if exception passed in) Pub...