Append options for PeriodicFileSystemWatcher

pull/1/head
unknown 4 years ago
parent f520eab6bb
commit 4d0d77bd62

@ -18,8 +18,11 @@ namespace ZeroLevel.Services.FileSystem
public event Action OnCompleteMovingFilesToTemporary = delegate { };
private readonly bool _autoRemoveTempFileAfterCallback = false;
private readonly bool _useSubdirectories = false;
public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action<FileMeta> callback, bool removeTempFileAfterCallback = false)
public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action<FileMeta> callback
, bool removeTempFileAfterCallback = false
, bool useSubdirectories = false)
{
if (string.IsNullOrWhiteSpace(watch_folder))
{
@ -29,6 +32,7 @@ namespace ZeroLevel.Services.FileSystem
{
throw new ArgumentNullException(nameof(callback));
}
_useSubdirectories = useSubdirectories;
_autoRemoveTempFileAfterCallback = removeTempFileAfterCallback;
_callback = callback;
_sourceFolder = watch_folder;
@ -168,7 +172,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
private string[] GetFilesFromSource()
{
string[] files = Directory.GetFiles(_sourceFolder, "*.*", SearchOption.TopDirectoryOnly);
string[] files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
Array.Sort<string>(files, FileNameSortCompare);
return files;
}

@ -6,16 +6,16 @@
</Description>
<Authors>ogoun</Authors>
<Company>ogoun</Company>
<AssemblyVersion>3.3.4.3</AssemblyVersion>
<PackageReleaseNotes>Refactoring</PackageReleaseNotes>
<AssemblyVersion>3.3.4.4</AssemblyVersion>
<PackageReleaseNotes>Additional options for PeriodicFileSystemWatcher</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2020</Copyright>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Version>3.3.4.3</Version>
<FileVersion>3.3.4.3</FileVersion>
<Version>3.3.4.4</Version>
<FileVersion>3.3.4.4</FileVersion>
<Platforms>AnyCPU;x64</Platforms>
<PackageIcon>zero.png</PackageIcon>
</PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.