diff --git a/FolderMonitor.UI/ConfigService.cs b/FolderMonitor.UI/ConfigService.cs
index 2f9a133..4673e82 100644
--- a/FolderMonitor.UI/ConfigService.cs
+++ b/FolderMonitor.UI/ConfigService.cs
@@ -132,7 +132,8 @@ void SetUserAccount(string username,string password)
cmd += "password= " + password;
var i = new Tools.Impersonator(username, null, password);
i.Dispose();
- }else
+ }
+ else
cmd += "obj= " + drpAccount.Text.Trim().Replace (" ","") ;
var process = new Process();
// process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
diff --git a/FolderMonitor.UI/ExcludedItemsControl.Designer.cs b/FolderMonitor.UI/ExcludedItemsControl.Designer.cs
index 23fca72..fa3d4de 100644
--- a/FolderMonitor.UI/ExcludedItemsControl.Designer.cs
+++ b/FolderMonitor.UI/ExcludedItemsControl.Designer.cs
@@ -1,4 +1,4 @@
-namespace RoboMirror.GUI
+namespace FolderMonitor.UI
{
partial class ExcludedItemsControl
{
diff --git a/FolderMonitor.UI/ExcludedItemsControl.cs b/FolderMonitor.UI/ExcludedItemsControl.cs
index 1e4d9e7..baf4e70 100644
--- a/FolderMonitor.UI/ExcludedItemsControl.cs
+++ b/FolderMonitor.UI/ExcludedItemsControl.cs
@@ -11,7 +11,7 @@
using System.IO;
using System.Windows.Forms;
-namespace RoboMirror.GUI
+namespace FolderMonitor.UI
{
public partial class ExcludedItemsControl : UserControl
{
diff --git a/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs b/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs
index 844d57e..17954ad 100644
--- a/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs
+++ b/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs
@@ -34,9 +34,9 @@ private void InitializeComponent()
this.button1 = new System.Windows.Forms.Button();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.filesGroupBox = new System.Windows.Forms.GroupBox();
- this.excludedFilesControl = new RoboMirror.GUI.ExcludedItemsControl();
+ this.excludedFilesControl = new FolderMonitor.UI.ExcludedItemsControl();
this.foldersGroupBox = new System.Windows.Forms.GroupBox();
- this.excludedFoldersControl = new RoboMirror.GUI.ExcludedItemsControl();
+ this.excludedFoldersControl = new FolderMonitor.UI.ExcludedItemsControl();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
@@ -153,7 +153,7 @@ private void InitializeComponent()
this.excludedFilesControl.BaseFolder = null;
this.excludedFilesControl.Font = this.Font;
this.excludedFilesControl.Location = new System.Drawing.Point(14, 22);
- this.excludedFilesControl.Mode = RoboMirror.GUI.ExcludedItemsMode.Files;
+ this.excludedFilesControl.Mode = FolderMonitor.UI.ExcludedItemsMode.Files;
this.excludedFilesControl.Name = "excludedFilesControl";
this.excludedFilesControl.Size = new System.Drawing.Size(491, 145);
this.excludedFilesControl.TabIndex = 0;
@@ -181,7 +181,7 @@ private void InitializeComponent()
| System.Windows.Forms.AnchorStyles.Right)));
this.excludedFoldersControl.BaseFolder = null;
this.excludedFoldersControl.Location = new System.Drawing.Point(14, 22);
- this.excludedFoldersControl.Mode = RoboMirror.GUI.ExcludedItemsMode.Folders;
+ this.excludedFoldersControl.Mode = FolderMonitor.UI.ExcludedItemsMode.Folders;
this.excludedFoldersControl.Name = "excludedFoldersControl";
this.excludedFoldersControl.Size = new System.Drawing.Size(482, 150);
this.excludedFoldersControl.TabIndex = 0;
@@ -226,8 +226,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button button1;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.GroupBox filesGroupBox;
- private RoboMirror.GUI.ExcludedItemsControl excludedFilesControl;
+ private FolderMonitor.UI.ExcludedItemsControl excludedFilesControl;
private System.Windows.Forms.GroupBox foldersGroupBox;
- private RoboMirror.GUI.ExcludedItemsControl excludedFoldersControl;
+ private FolderMonitor.UI.ExcludedItemsControl excludedFoldersControl;
}
}
\ No newline at end of file
diff --git a/FolderMonitor.UI/FileDropTargetWrapper.cs b/FolderMonitor.UI/FileDropTargetWrapper.cs
index 376897a..a1f698d 100644
--- a/FolderMonitor.UI/FileDropTargetWrapper.cs
+++ b/FolderMonitor.UI/FileDropTargetWrapper.cs
@@ -10,7 +10,7 @@
using System.Text;
using System.Windows.Forms;
-namespace RoboMirror
+namespace FolderMonitor
{
[Flags]
public enum FileDropMode
diff --git a/FolderMonitor.UI/FolderMonitor.UI.csproj b/FolderMonitor.UI/FolderMonitor.UI.csproj
index ff0e303..10cef53 100644
--- a/FolderMonitor.UI/FolderMonitor.UI.csproj
+++ b/FolderMonitor.UI/FolderMonitor.UI.csproj
@@ -79,162 +79,57 @@
-
- AlphaFS\NativeError.cs
-
-
- AlphaFS\Network\DfsInfo.cs
-
-
- AlphaFS\Network\DfsStorageInfo.cs
-
-
- AlphaFS\Network\Enumerations\AccessPermissions.cs
-
-
- AlphaFS\Network\Enumerations\Connect.cs
-
-
- AlphaFS\Network\Enumerations\DfsNamespaceFlavors.cs
-
-
- AlphaFS\Network\Enumerations\DfsPropertyFlags.cs
-
-
- AlphaFS\Network\Enumerations\DfsStorageStates.cs
-
-
- AlphaFS\Network\Enumerations\DfsTargetPriorityClass.cs
-
-
- AlphaFS\Network\Enumerations\DfsVolumeStates.cs
-
-
- AlphaFS\Network\Enumerations\ResourceDisplayType.cs
-
-
- AlphaFS\Network\Enumerations\ResourceScope.cs
-
-
- AlphaFS\Network\Enumerations\ResourceType.cs
-
-
- AlphaFS\Network\Enumerations\ResourceUsage.cs
-
-
- AlphaFS\Network\Enumerations\ShareInfoLevel.cs
-
-
- AlphaFS\Network\Enumerations\ShareResourceTypes.cs
-
-
- AlphaFS\Network\Enumerations\ShareType.cs
-
-
- AlphaFS\Network\Host Class\Connect.cs
-
-
- AlphaFS\Network\Host Class\DriveConnection.cs
-
-
- AlphaFS\Network\Host Class\EnumerateDrives.cs
-
-
- AlphaFS\Network\Host Class\EnumerateOpenResources.cs
-
-
- AlphaFS\Network\Host Class\Host.cs
-
-
- AlphaFS\Network\Host Class\ServerMessageBlock.cs
-
-
- AlphaFS\Network\Native Methods\NativeMethods.cs
-
-
- AlphaFS\Network\Native Methods\NativeMethods.WindowsNetworking.cs
-
-
- AlphaFS\Network\Native Structures\CONNECTION_INFO_1.cs
-
-
- AlphaFS\Network\Native Structures\DFS_INFO_200.cs
-
-
- AlphaFS\Network\Native Structures\DFS_INFO_300.cs
-
-
- AlphaFS\Network\Native Structures\DFS_INFO_9.cs
-
-
- AlphaFS\Network\Native Structures\DFS_STORAGE_INFO_1.cs
-
-
- AlphaFS\Network\Native Structures\DFS_TARGET_PRIORITY.cs
-
-
- AlphaFS\Network\Native Structures\FILE_INFO_3.cs
-
-
- AlphaFS\Network\Native Structures\NETRESOURCE.cs
-
-
- AlphaFS\Network\Native Structures\REMOTE_NAME_INFO.cs
-
-
- AlphaFS\Network\Native Structures\SHARE_INFO_1.cs
-
-
- AlphaFS\Network\Native Structures\SHARE_INFO_1005.cs
+
+ clsEncrypt.cs
-
- AlphaFS\Network\Native Structures\SHARE_INFO_2.cs
+
+ Impersonator.cs
-
- AlphaFS\Network\Native Structures\SHARE_INFO_503.cs
+
+ MyExtensions.cs
-
- AlphaFS\Network\OpenConnectionInfo.cs
+
+ Network\Connect.cs
-
- AlphaFS\Network\OpenResourceInfo.cs
+
+ Network\Enums\Connect.cs
-
- AlphaFS\Network\ShareInfo.cs
+
+ Network\Enums\ResourceDisplayType.cs
-
- AlphaFS\OperatingSystem.cs
+
+ Network\Enums\ResourceScope.cs
-
- AlphaFS\Resources.Designer.cs
+
+ Network\Enums\ResourceType.cs
-
- AlphaFS\SafeGlobalMemoryBufferHandle.cs
+
+ Network\Enums\ResourceUsage.cs
-
- AlphaFS\SafeNativeMemoryBufferHandle.cs
+
+ Network\Native Structures\NETRESOURCE.cs
-
- AlphaFS\Utils.cs
+
+ Network\NativeMethods.WindowsNetworking.cs
-
- AlphaFS\Win32Errors.cs
+
+ Network\Resources.Designer.cs
+ True
+ True
+ Resources.resx
-
- clsEncrypt.cs
+
+ Network\SafeGlobalMemoryBufferHandle.cs
-
- Impersonator.cs
+
+ Network\SafeNativeMemoryBufferHandle.cs
-
- MyExtensions.cs
+
+ Network\Win32Errors.cs
PathCredentials.cs
-
- UNCAccessWithCredentials.cs
- Form
@@ -254,6 +149,7 @@
ExcludedItemsDialog.cs
+ Form
@@ -277,13 +173,20 @@
+
+ True
+ True
+ Resources.resx
+ Component
-
- AlphaFS\Resources.resx
+
+ Network\Resources.resx
+ ResXFileCodeGenerator
+ Resources.Designer.csConfigService.cs
@@ -305,14 +208,9 @@
ResXFileCodeGenerator
- Resources.Designer.csDesigner
+ Resources.Designer.cs
-
- True
- Resources.resx
- True
-
@@ -361,8 +259,8 @@
-
+
diff --git a/FolderMonitor.UI/GlobalSuppressions.cs b/FolderMonitor.UI/GlobalSuppressions.cs
new file mode 100644
index 0000000..2d3f3f2
Binary files /dev/null and b/FolderMonitor.UI/GlobalSuppressions.cs differ
diff --git a/FolderMonitor.UI/MainForm.cs b/FolderMonitor.UI/MainForm.cs
index f9a627c..c850a89 100644
--- a/FolderMonitor.UI/MainForm.cs
+++ b/FolderMonitor.UI/MainForm.cs
@@ -363,7 +363,9 @@ private void stopservice_Click(object sender, EventArgs e)
{
_service.Stop();
}
+#pragma warning disable CS0168 // The variable 'er' is declared but never used
catch (Exception er)
+#pragma warning restore CS0168 // The variable 'er' is declared but never used
{
_service.Refresh();
if (_service.Status != ServiceControllerStatus.Stopped && _service.Status != ServiceControllerStatus.StopPending)
diff --git a/FolderMonitor.UI/Properties/Resources.resx b/FolderMonitor.UI/Properties/Resources.resx
index da0c98c..9898e5a 100644
--- a/FolderMonitor.UI/Properties/Resources.resx
+++ b/FolderMonitor.UI/Properties/Resources.resx
@@ -218,6 +218,6 @@
..\Resources\Robocopy.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- ..\bin\Release\FolderMonitor.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ ..\Resources\FolderMonitor.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
\ No newline at end of file
diff --git a/FolderMonitor.UI/Resources/FolderMonitor.exe b/FolderMonitor.UI/Resources/FolderMonitor.exe
index f87de41..0b85965 100644
Binary files a/FolderMonitor.UI/Resources/FolderMonitor.exe and b/FolderMonitor.UI/Resources/FolderMonitor.exe differ
diff --git a/FolderMonitor.UI/ServiceConfig.cs b/FolderMonitor.UI/ServiceConfig.cs
index a7cdbdf..e31ad63 100644
--- a/FolderMonitor.UI/ServiceConfig.cs
+++ b/FolderMonitor.UI/ServiceConfig.cs
@@ -9,95 +9,96 @@
using System.Xml.Serialization;
-
-internal sealed partial class ServiceConfig
+namespace FolderMonitor
{
- public static string _configFile = "";
- private static ServiceConfig defaultInstance = (new ServiceConfig());
-
- public static ServiceConfig Default
+ internal sealed partial class ServiceConfig
{
- get
+ public static string _configFile = "";
+ private static ServiceConfig defaultInstance = (new ServiceConfig());
+
+ public static ServiceConfig Default
{
+ get
+ {
- return defaultInstance;
+ return defaultInstance;
+ }
}
- }
- public ServiceConfig()
- {
+ public ServiceConfig()
+ {
- }
+ }
- public static string RoboCopyOptions = "/E /FFT /Z /W:20 /R:100 /ETA /MON:1"; // /MT causes issues
- public static string ServiceFilename = "FolderMonitor.exe";
- public static string ServiceConfigFilename = "FolderMonitor.exe.conf";
+ public static string RoboCopyOptions = "/E /FFT /Z /W:20 /R:100 /ETA /MON:1"; // /MT causes issues
+ public static string ServiceFilename = "FolderMonitor.exe";
+ public static string ServiceConfigFilename = "FolderMonitor.exe.conf";
- public static string FolderMonitorLogFilename = "FolderMonitor.log";
+ public static string FolderMonitorLogFilename = "FolderMonitor.log";
- public void SaveChanges(List paths)
- {
- var items = new List(paths.Select(x => (PathFromAndTo)x.Clone()));
- foreach (var item in items)
+ public void SaveChanges(List paths)
{
- if (!string.IsNullOrWhiteSpace(item.From.Password))
- item.From.Password = item.From.Password.Encrypts();
+ var items = new List(paths.Select(x => (PathFromAndTo)x.Clone()));
+ foreach (var item in items)
+ {
+ if (!string.IsNullOrWhiteSpace(item.From.Password))
+ item.From.Password = item.From.Password.Encrypts();
- if (!string.IsNullOrWhiteSpace(item.To.Password))
- item.To.Password = item.To.Password.Encrypts();
+ if (!string.IsNullOrWhiteSpace(item.To.Password))
+ item.To.Password = item.To.Password.Encrypts();
+ }
+ XmlSerializer xs = new XmlSerializer(typeof(List));
+ TextWriter tw = new StreamWriter(_configFile);
+ xs.Serialize(tw, items);
+ tw.Close();
+ tw.Dispose();
}
- XmlSerializer xs = new XmlSerializer(typeof(List));
- TextWriter tw = new StreamWriter(_configFile);
- xs.Serialize(tw, items);
- tw.Close();
- tw.Dispose();
- }
- public static string RobocopyPath
- {
- get
+ public static string RobocopyPath
{
- var r = Environment.GetFolderPath(Environment.SpecialFolder.System);
- r = Path.Combine(r, "robocopy.exe");
- return r;
+ get
+ {
+ var r = Environment.GetFolderPath(Environment.SpecialFolder.System);
+ r = Path.Combine(r, "robocopy.exe");
+ return r;
+ }
}
- }
- public static bool DoesRoboCopExist()
- {
-
- return File.Exists(RobocopyPath);
-
-
- }
+ public static bool DoesRoboCopExist()
+ {
- public List GetAllTasks(bool EnabaledOnly)
- {
+ return File.Exists(RobocopyPath);
+
+
+ }
- List items = new List();
- if (!File.Exists(_configFile))
- return items;
- using (var sr = new FileStream(_configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ public List GetAllTasks(bool EnabaledOnly)
{
- XmlSerializer xs = new XmlSerializer(typeof(List));
- var xitems = (List)xs.Deserialize(sr);
- foreach (var item in xitems)
+ List items = new List();
+ if (!File.Exists(_configFile))
+ return items;
+ using (var sr = new FileStream(_configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
- if (EnabaledOnly && !item.IsEnabled) continue;
- if (!string.IsNullOrWhiteSpace(item.From.Password))
- item.From.Password = item.From.Password.Decrypts();
-
- if (!string.IsNullOrWhiteSpace(item.To.Password))
- item.To.Password = item.To.Password.Decrypts();
- items.Add(item);
+ XmlSerializer xs = new XmlSerializer(typeof(List));
+ var xitems = (List)xs.Deserialize(sr);
+
+ foreach (var item in xitems)
+ {
+ if (EnabaledOnly && !item.IsEnabled) continue;
+ if (!string.IsNullOrWhiteSpace(item.From.Password))
+ item.From.Password = item.From.Password.Decrypts();
+
+ if (!string.IsNullOrWhiteSpace(item.To.Password))
+ item.To.Password = item.To.Password.Decrypts();
+ items.Add(item);
+ }
+ sr.Close();
+
+ return items;
}
- sr.Close();
-
- return items;
}
- }
+ }
}
-
diff --git a/FolderMonitor.UI/ServiceManager.cs b/FolderMonitor.UI/ServiceManager.cs
index 2d5d4b2..fcf1c7e 100644
--- a/FolderMonitor.UI/ServiceManager.cs
+++ b/FolderMonitor.UI/ServiceManager.cs
@@ -17,9 +17,15 @@ public class ServiceManager : ServiceController
public static string _FolderMonitorServiceName = "DirectoryMonitor";
#region Private : Fields
+#pragma warning disable CS0169 // The field 'ServiceManager.m_bExists' is never used
private bool m_bExists;
+#pragma warning restore CS0169 // The field 'ServiceManager.m_bExists' is never used
+#pragma warning disable CS0169 // The field 'ServiceManager.m_bExistsAvailable' is never used
private bool m_bExistsAvailable;
+#pragma warning restore CS0169 // The field 'ServiceManager.m_bExistsAvailable' is never used
+#pragma warning disable CS0169 // The field 'ServiceManager.m_sRemoteResource' is never used
private string m_sRemoteResource;
+#pragma warning restore CS0169 // The field 'ServiceManager.m_sRemoteResource' is never used
private ServiceStartMode m_eStartMode;
private bool m_bStartModeAvailable;
diff --git a/FolderMonitor.sln b/FolderMonitor.sln
index 35e5169..f057c4a 100644
--- a/FolderMonitor.sln
+++ b/FolderMonitor.sln
@@ -8,6 +8,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FolderMonitor.UI", "FolderMonitor.UI\FolderMonitor.UI.csproj", "{9BBDFE62-CB4C-48CC-BCF0-858D22C311E2}"
EndProject
Global
+ GlobalSection(Performance) = preSolution
+ HasPerformanceSessions = true
+ EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
@@ -25,16 +28,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(TeamFoundationVersionControl) = preSolution
- SccNumberOfProjects = 3
- SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
- SccTeamFoundationServer = https://ucas-code.visualstudio.com/
- SccLocalPath0 = .
- SccProjectUniqueName1 = FolderMonitor\\FolderMonitor.csproj
- SccProjectName1 = FolderMonitor
- SccLocalPath1 = FolderMonitor
- SccProjectUniqueName2 = FolderMonitor.UI\\FolderMonitor.UI.csproj
- SccProjectName2 = FolderMonitor.UI
- SccLocalPath2 = FolderMonitor.UI
- EndGlobalSection
EndGlobal
diff --git a/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs b/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs
deleted file mode 100644
index d4416c5..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Text;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Information about an alternate data stream.
- ///
- public struct AlternateDataStreamInfo
- {
- #region Constructor
-
- internal AlternateDataStreamInfo(string fullPath, NativeMethods.WIN32_FIND_STREAM_DATA findData) : this()
- {
- StreamName = ParseStreamName(findData.cStreamName);
- Size = findData.StreamSize;
- _fullPath = fullPath;
- }
-
- #endregion // Constructor
-
- #region Public Properties
-
- /// Gets the name of the alternate data stream.
- /// This value is an empty string for the default stream (:$DATA), and for any other data stream it contains the name of the stream.
- /// The name of the stream.
- public string StreamName { get; private set; }
-
- /// Gets the size of the stream.
- public long Size { get; private set; }
-
-
- private readonly string _fullPath;
-
- /// Gets the full path to the stream.
- ///
- /// This is a path in long path format that can be passed to to open the stream if
- /// or
- /// is specified.
- ///
- /// The full path to the stream in long path format.
- public string FullPath
- {
- get { return _fullPath + Path.StreamSeparator + StreamName + Path.StreamDataLabel; }
- }
-
- #endregion // Public Properties
-
- #region Public Methods
-
- /// Returns the hash code for this instance.
- /// A 32-bit signed integer that is the hash code for this instance.
- public override int GetHashCode()
- {
- return StreamName.GetHashCode();
- }
-
- /// Indicates whether this instance and a specified object are equal.
- /// The object to compare with the current instance.
- ///
- /// true if and this instance are the same type and represent the same value; otherwise, false.
- ///
- public override bool Equals(object obj)
- {
- if (obj is AlternateDataStreamInfo)
- {
- AlternateDataStreamInfo other = (AlternateDataStreamInfo) obj;
- return StreamName.Equals(other.StreamName, StringComparison.OrdinalIgnoreCase) && Size.Equals(other.Size);
- }
-
- return false;
- }
-
- /// Equality operator.
- /// The first operand.
- /// The second operand.
- /// The result of the operation.
- public static bool operator ==(AlternateDataStreamInfo first, AlternateDataStreamInfo second)
- {
- return first.Equals(second);
- }
-
- /// Inequality operator.
- /// The first operand.
- /// The second operand.
- /// The result of the operation.
- public static bool operator !=(AlternateDataStreamInfo first, AlternateDataStreamInfo second)
- {
- return !first.Equals(second);
- }
-
- #endregion // Public Methods
-
- #region Private Methods
-
- private static string ParseStreamName(string input)
- {
- if (input == null || input.Length < 2)
- return string.Empty;
-
- if (input[0] != Path.StreamSeparatorChar)
- throw new ArgumentException(Resources.Invalid_Stream_Name);
-
- var sb = new StringBuilder();
- for (int i = 1; i < input.Length; i++)
- {
- if (input[i] == Path.StreamSeparatorChar)
- break;
-
- sb.Append(input[i]);
- }
-
- return sb.ToString();
- }
-
- #endregion // Private Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs b/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs
deleted file mode 100644
index 3a03001..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Alphaleonis.Win32.Security;
-using Microsoft.Win32.SafeHandles;
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-using SecurityNativeMethods = Alphaleonis.Win32.Security.NativeMethods;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// The provides access to data associated with a specific file or directory, including security information and alternative data streams, for backup and restore operations.
- /// This class uses the BackupRead,
- /// BackupSeek and
- /// BackupWrite functions from the Win32 API to provide access to the file or directory.
- ///
- public sealed class BackupFileStream : Stream
- {
- #region Private Fields
-
- private readonly bool _canRead;
- private readonly bool _canWrite;
- private readonly bool _processSecurity;
-
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- private IntPtr _context = IntPtr.Zero;
-
- #endregion // Private Fields
-
- #region Construction and Destruction
-
- /// Initializes a new instance of the class with the specified path and creation mode.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// The file will be opened for exclusive access for both reading and writing.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(string path, FileMode mode)
- : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, FileSystemRights.Read | FileSystemRights.Write, FileShare.None, true, PathFormat.RelativePath), FileSystemRights.Read | FileSystemRights.Write)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode and access rights.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// The file will be opened for exclusive access.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(string path, FileMode mode, FileSystemRights access)
- : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, access, FileShare.None, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share)
- : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, and additional file attributes.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- /// A constant that specifies additional file attributes.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes)
- : this(File.CreateFileCore(null, path, attributes, null, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, additional file attributes, access control and audit security.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- /// A constant that specifies additional file attributes.
- /// A constant that determines the access control and audit security for the file. This parameter This parameter may be .
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes, FileSecurity security)
- : this(File.CreateFileCore(null, path, attributes, security, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- #region Transactional
-
- /// Initializes a new instance of the class with the specified path and creation mode.
- /// The transaction.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// The file will be opened for exclusive access for both reading and writing.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(KernelTransaction transaction, string path, FileMode mode)
- : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, FileSystemRights.Read | FileSystemRights.Write, FileShare.None, true, PathFormat.RelativePath), FileSystemRights.Read | FileSystemRights.Write)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode and access rights.
- /// The transaction.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// The file will be opened for exclusive access.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access)
- : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, access, FileShare.None, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission.
- /// The transaction.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share)
- : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, and additional file attributes.
- /// The transaction.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- /// A constant that specifies additional file attributes.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes)
- : this(File.CreateFileCore(transaction, path, attributes, null, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, additional file attributes, access control and audit security.
- /// The transaction.
- /// A relative or absolute path for the file that the current object will encapsulate.
- /// A constant that determines how to open or create the file.
- /// A constant that determines the access rights to use when creating access and audit rules for the file.
- /// A constant that determines how the file will be shared by processes.
- /// A constant that specifies additional file attributes.
- /// A constant that determines the access control and audit security for the file. This parameter This parameter may be .
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- [SecurityCritical]
- public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes, FileSecurity security)
- : this(File.CreateFileCore(transaction, path, attributes, security, mode, access, share, true, PathFormat.RelativePath), access)
- {
- }
-
- #endregion // Transacted
-
-
- #region Stream
-
- /// Initializes a new instance of the class for the specified file handle, with the specified read/write permission.
- /// A file handle for the file that this object will encapsulate.
- /// A constant that gets the and properties of the object.
-
- [SecurityCritical]
- public BackupFileStream(SafeFileHandle handle, FileSystemRights access)
- {
- if (handle == null)
- throw new ArgumentNullException("handle", Resources.Handle_Is_Invalid);
-
- if (handle.IsInvalid)
- {
- handle.Close();
- throw new ArgumentException(Resources.Handle_Is_Invalid);
- }
-
- if (handle.IsClosed)
- throw new ArgumentException(Resources.Handle_Is_Closed);
-
-
- SafeFileHandle = handle;
-
- _canRead = (access & FileSystemRights.ReadData) != 0;
- _canWrite = (access & FileSystemRights.WriteData) != 0;
- _processSecurity = true;
- }
-
- #endregion // Stream
-
- #endregion // Construction and Destruction
-
- #region NotSupportedException
-
- /// When overridden in a derived class, gets the length in bytes of the stream.
- /// This method always throws an exception.
- ///
- public override long Length
- {
- get { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); }
- }
-
- /// When overridden in a derived class, gets or sets the position within the current stream.
- /// This method always throws an exception.
- ///
- public override long Position
- {
- get { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); }
- set { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); }
- }
-
-
- /// When overridden in a derived class, sets the position within the current stream.
- /// A byte offset relative to the parameter.
- /// A value of type indicating the reference point used to obtain the new position.
- /// The new position within the current stream.
- /// This stream does not support seeking using this method, and calling this method will always throw . See for an alternative way of seeking forward.
- ///
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException(Resources.No_Stream_Seeking_Support);
- }
-
-
- /// When overridden in a derived class, sets the length of the current stream.
- /// The desired length of the current stream in bytes.
- /// This method is not supported by the class, and calling it will always generate a .
- ///
- public override void SetLength(long value)
- {
- throw new NotSupportedException(Resources.No_Stream_Seeking_Support);
- }
-
- #endregion // NotSupportedException
-
- #region Properties
-
- /// Gets a value indicating whether the current stream supports reading.
- /// if the stream supports reading, otherwise.
- public override bool CanRead
- {
- get { return _canRead; }
- }
-
- /// Gets a value indicating whether the current stream supports seeking.
- /// This method always returns .
- public override bool CanSeek
- {
- get { return false; }
- }
-
- /// Gets a value indicating whether the current stream supports writing.
- /// if the stream supports writing, otherwise.
- public override bool CanWrite
- {
- get { return _canWrite; }
- }
-
- /// Gets a object that represents the operating system file handle for the file that the current object encapsulates.
- /// A object that represents the operating system file handle for the file that
- /// the current object encapsulates.
- private SafeFileHandle SafeFileHandle { get; set; }
-
- #endregion // Properties
-
- #region Methods
-
- /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
- /// This method will not backup the access-control list (ACL) data for the file or directory.
- ///
- /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between
- /// and ( + - 1) replaced by the bytes read from the
- /// current source.
- ///
- ///
- /// The zero-based byte offset in at which to begin storing the data read from the current stream.
- ///
- /// The maximum number of bytes to be read from the current stream.
- ///
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not
- /// currently available, or zero (0) if the end of the stream has been reached.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public override int Read(byte[] buffer, int offset, int count)
- {
- return Read(buffer, offset, count, false);
- }
-
- /// When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
- /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values
- /// between and ( + - 1) replaced by the bytes read from the current source.
- /// The zero-based byte offset in at which to begin storing the data read from the current stream.
- /// The maximum number of bytes to be read from the current stream.
- /// Indicates whether the function will backup the access-control list (ACL) data for the file or directory.
- ///
- /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not
- /// currently available, or zero (0) if the end of the stream has been reached.
- ///
- ///
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
- [SecurityCritical]
- public int Read(byte[] buffer, int offset, int count, bool processSecurity)
- {
- if (buffer == null)
- throw new ArgumentNullException("buffer");
-
- if (!CanRead)
- throw new NotSupportedException("Stream does not support reading");
-
- if (offset + count > buffer.Length)
- throw new ArgumentException("The sum of offset and count is larger than the size of the buffer.");
-
- if (offset < 0)
- throw new ArgumentOutOfRangeException("offset", offset, Resources.Negative_Offset);
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count", count, Resources.Negative_Count);
-
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(count))
- {
- uint numberOfBytesRead;
-
- if (!NativeMethods.BackupRead(SafeFileHandle, safeBuffer, (uint)safeBuffer.Capacity, out numberOfBytesRead, false, processSecurity, ref _context))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
-
- // See File.GetAccessControlCore(): .CopyTo() does not work there?
- safeBuffer.CopyTo(buffer, offset, count);
-
- return (int)numberOfBytesRead;
- }
- }
-
-
- /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- ///
- /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- ///
- /// An array of bytes. This method copies bytes from to the current stream.
- /// The zero-based byte offset in at which to begin copying bytes to the current stream.
- /// The number of bytes to be written to the current stream.
- ///
- ///
- ///
- ///
- ///
- /// This method will not process the access-control list (ACL) data for the file or directory.
- public override void Write(byte[] buffer, int offset, int count)
- {
- Write(buffer, offset, count, false);
- }
-
- /// When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- /// An array of bytes. This method copies bytes from to the current stream.
- /// The zero-based byte offset in at which to begin copying bytes to the current stream.
- /// The number of bytes to be written to the current stream.
- /// Specifies whether the function will restore the access-control list (ACL) data for the file or directory.
- /// If this is you need to specify and access when
- /// opening the file or directory handle. If the handle does not have those access rights, the operating system denies
- /// access to the ACL data, and ACL data restoration will not occur.
- ///
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
- [SecurityCritical]
- public void Write(byte[] buffer, int offset, int count, bool processSecurity)
- {
- if (buffer == null)
- throw new ArgumentNullException("buffer");
-
- if (offset < 0)
- throw new ArgumentOutOfRangeException("offset", offset, Resources.Negative_Offset);
-
- if (count < 0)
- throw new ArgumentOutOfRangeException("count", count, Resources.Negative_Count);
-
- if (offset + count > buffer.Length)
- throw new ArgumentException(Resources.Buffer_Not_Large_Enough);
-
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(count))
- {
- safeBuffer.CopyFrom(buffer, offset, count);
-
- uint bytesWritten;
-
- if (!NativeMethods.BackupWrite(SafeFileHandle, safeBuffer, (uint)safeBuffer.Capacity, out bytesWritten, false, processSecurity, ref _context))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
- }
- }
-
-
- /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
- public override void Flush()
- {
- if (!NativeMethods.FlushFileBuffers(SafeFileHandle))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
- }
-
-
- /// Skips ahead the specified number of bytes from the current stream.
- /// This method represents the Win32 API implementation of BackupSeek.
- ///
- /// Applications use the method to skip portions of a data stream that cause errors. This function does not
- /// seek across stream headers. For example, this function cannot be used to skip the stream name. If an application
- /// attempts to seek past the end of a substream, the function fails, the return value indicates the actual number of bytes
- /// the function seeks, and the file position is placed at the start of the next stream header.
- ///
- ///
- /// The number of bytes to skip.
- /// The number of bytes actually skipped.
- [SecurityCritical]
- public long Skip(long bytes)
- {
- uint lowSought, highSought;
- if (!NativeMethods.BackupSeek(SafeFileHandle, NativeMethods.GetLowOrderDword(bytes), NativeMethods.GetHighOrderDword(bytes), out lowSought, out highSought, ref _context))
- {
- int lastError = Marshal.GetLastWin32Error();
-
- // Error Code 25 indicates a seek error, we just skip that here.
- if (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_SEEK)
- NativeError.ThrowException(lastError);
- }
-
- return NativeMethods.ToLong(highSought, lowSought);
- }
-
-
- /// Gets a object that encapsulates the access control list (ACL) entries for the file described by the current object.
- ///
- ///
- /// A object that encapsulates the access control list (ACL) entries for the file described by the current
- /// object.
- ///
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- [SecurityCritical]
- public FileSecurity GetAccessControl()
- {
- IntPtr pSidOwner, pSidGroup, pDacl, pSacl;
- SafeGlobalMemoryBufferHandle pSecurityDescriptor;
-
- uint lastError = SecurityNativeMethods.GetSecurityInfo(SafeFileHandle, ObjectType.FileObject,
- SecurityInformation.Group | SecurityInformation.Owner | SecurityInformation.Label | SecurityInformation.Dacl | SecurityInformation.Sacl,
- out pSidOwner, out pSidGroup, out pDacl, out pSacl, out pSecurityDescriptor);
-
- try
- {
- if (lastError != Win32Errors.ERROR_SUCCESS)
- NativeError.ThrowException((int)lastError);
-
- if (pSecurityDescriptor != null && pSecurityDescriptor.IsInvalid)
- {
- pSecurityDescriptor.Close();
- throw new IOException(Resources.Returned_Invalid_Security_Descriptor);
- }
-
- uint length = SecurityNativeMethods.GetSecurityDescriptorLength(pSecurityDescriptor);
-
- byte[] managedBuffer = new byte[length];
-
-
- // .CopyTo() does not work there?
- if (pSecurityDescriptor != null)
- pSecurityDescriptor.CopyTo(managedBuffer, 0, (int) length);
-
-
- var fs = new FileSecurity();
- fs.SetSecurityDescriptorBinaryForm(managedBuffer);
-
- return fs;
- }
- finally
- {
- if (pSecurityDescriptor != null)
- pSecurityDescriptor.Close();
- }
- }
-
-
- /// Applies access control list (ACL) entries described by a object to the file described by the current object.
- /// A object that describes an ACL entry to apply to the current file.
- [SecurityCritical]
- public void SetAccessControl(ObjectSecurity fileSecurity)
- {
- File.SetAccessControlCore(null, SafeFileHandle, fileSecurity, AccessControlSections.All, PathFormat.LongFullPath);
- }
-
-
- /// Prevents other processes from changing the while permitting read access.
- /// The beginning of the range to lock. The value of this parameter must be equal to or greater than zero (0).
- /// The range to be locked.
- ///
- ///
- [SecurityCritical]
- public void Lock(long position, long length)
- {
- if (position < 0)
- throw new ArgumentOutOfRangeException("position", position, Resources.Unlock_Position_Negative);
-
- if (length < 0)
- throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length);
-
- if (!NativeMethods.LockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length)))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
- }
-
-
- /// Allows access by other processes to all or part of a file that was previously locked.
- /// The beginning of the range to unlock.
- /// The range to be unlocked.
- ///
- ///
- ///
- [SecurityCritical]
- public void Unlock(long position, long length)
- {
- if (position < 0)
- throw new ArgumentOutOfRangeException("position", position, Resources.Unlock_Position_Negative);
-
- if (length < 0)
- throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length);
-
- if (!NativeMethods.UnlockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length)))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
- }
-
-
- /// Reads a stream header from the current .
- /// The stream header read from the current , or if the end-of-file
- /// was reached before the required number of bytes of a header could be read.
- ///
- /// The stream must be positioned at where an actual header starts for the returned object to represent valid
- /// information.
- [SecurityCritical]
- public BackupStreamInfo ReadStreamInfo()
- {
- var sizeOf = Marshal.SizeOf(typeof(NativeMethods.WIN32_STREAM_ID));
-
- using (var hBuf = new SafeGlobalMemoryBufferHandle(sizeOf))
- {
- uint numberOfBytesRead;
-
- if (!NativeMethods.BackupRead(SafeFileHandle, hBuf, (uint) sizeOf, out numberOfBytesRead, false, _processSecurity, ref _context))
- NativeError.ThrowException();
-
-
- if (numberOfBytesRead == 0)
- return null;
-
-
- if (numberOfBytesRead < sizeOf)
- throw new IOException(Resources.Read_Incomplete_Header);
-
- var streamID = hBuf.PtrToStructure(0);
-
- uint nameLength = (uint) Math.Min(streamID.dwStreamNameSize, hBuf.Capacity);
-
-
- if (!NativeMethods.BackupRead(SafeFileHandle, hBuf, nameLength, out numberOfBytesRead, false, _processSecurity, ref _context))
- NativeError.ThrowException();
-
- string name = hBuf.PtrToStringUni(0, (int) nameLength/2);
-
- return new BackupStreamInfo(streamID, name);
- }
- }
-
- #endregion // Methods
-
- #region Disposable Members
-
- /// Releases the unmanaged resources used by the and optionally releases the managed resources.
- /// to release both managed and unmanaged resources; to release only unmanaged resources.
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
- protected override void Dispose(bool disposing)
- {
- // If one of the constructors previously threw an exception,
- // than the object hasn't been initialized properly and call from finalize will fail.
-
- if (SafeFileHandle != null && !SafeFileHandle.IsInvalid)
- {
- if (_context != IntPtr.Zero)
- {
- try
- {
- uint temp;
-
- // MSDN: To release the memory used by the data structure, call BackupRead with the bAbort parameter set to TRUE when the backup operation is complete.
- if (!NativeMethods.BackupRead(SafeFileHandle, new SafeGlobalMemoryBufferHandle(), 0, out temp, true, false, ref _context))
- NativeError.ThrowException(Marshal.GetLastWin32Error());
- }
- finally
- {
- _context = IntPtr.Zero;
- SafeFileHandle.Close();
- }
- }
- }
-
- base.Dispose(disposing);
- }
-
- /// Releases unmanaged resources and performs other cleanup operations before the is reclaimed by garbage collection.
- ~BackupFileStream()
- {
- Dispose(false);
- }
-
- #endregion // Disposable Members
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs b/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs
deleted file mode 100644
index 2bc85a5..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// The structure contains stream header data.
- ///
- public sealed class BackupStreamInfo
- {
- #region Private Fields
-
- private readonly long m_size;
- private readonly string m_name;
- private readonly BackupStreamType m_streamType;
- private readonly StreamAttributes m_attributes;
-
- #endregion
-
- #region Constructor
-
- /// Initializes a new instance of the class.
- /// The stream ID.
- /// The name.
- internal BackupStreamInfo(NativeMethods.WIN32_STREAM_ID streamID, string name)
- {
- m_name = name;
- m_size = (long) streamID.Size;
- m_attributes = streamID.dwStreamAttributes;
- m_streamType = streamID.dwStreamId;
- }
-
- #endregion
-
- #region Public Properties
-
- /// Gets the size of the data in the substream, in bytes.
- /// The size of the data in the substream, in bytes.
- public long Size
- {
- get { return m_size; }
- }
-
- /// Gets a string that specifies the name of the alternative data stream.
- /// A string that specifies the name of the alternative data stream.
- public string Name
- {
- get { return m_name; }
- }
-
- /// Gets the type of the data in the stream.
- /// The type of the data in the stream.
- public BackupStreamType StreamType
- {
- get { return m_streamType; }
- }
-
- /// Gets the attributes of the data to facilitate cross-operating system transfer.
- /// Attributes of the data to facilitate cross-operating system transfer.
- public StreamAttributes Attributes
- {
- get { return m_attributes; }
- }
-
- #endregion // Public Properties
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs b/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs
deleted file mode 100644
index e46dbcd..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- #region ByHandleFileInfo
-
- /// Contains information that the GetFileInformationByHandle function retrieves.
- [SerializableAttribute]
- [SecurityCritical]
- public sealed class ByHandleFileInfo
- {
- #region Constructor
-
- internal ByHandleFileInfo(NativeMethods.BY_HANDLE_FILE_INFORMATION fibh)
- {
- CreationTimeUtc = DateTime.FromFileTimeUtc(fibh.ftCreationTime);
- LastAccessTimeUtc = DateTime.FromFileTimeUtc(fibh.ftLastAccessTime);
- LastWriteTimeUtc = DateTime.FromFileTimeUtc(fibh.ftLastWriteTime);
-
- Attributes = fibh.dwFileAttributes;
- FileIndex = NativeMethods.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow);
- FileSize = NativeMethods.ToLong(fibh.nFileSizeHigh, fibh.nFileSizeLow);
- NumberOfLinks = fibh.nNumberOfLinks;
- VolumeSerialNumber = fibh.dwVolumeSerialNumber;
- }
-
- #endregion // Constructor
-
- #region Properties
-
- #region Attributes
-
- /// Gets the file attributes.
- /// The file attributes.
- public FileAttributes Attributes { get; private set; }
-
- #endregion // Attributes
-
- #region CreationTime
-
- /// Gets the time this entry was created.
- /// The time this entry was created.
- public DateTime CreationTime
- {
- get { return CreationTimeUtc.ToLocalTime(); }
- }
-
- #endregion // CreationTime
-
- #region CreationTimeUtc
-
- /// Gets the time, in coordinated universal time (UTC), this entry was created.
- /// The time, in coordinated universal time (UTC), this entry was created.
- public DateTime CreationTimeUtc { get; private set; }
-
- #endregion // CreationTimeUtc
-
- #region LastAccessTime
-
- /// Gets the time this entry was last accessed.
- /// For a file, the structure specifies the last time that a file is read from or written to.
- /// For a directory, the structure specifies when the directory is created.
- /// For both files and directories, the specified date is correct, but the time of day is always set to midnight.
- /// If the underlying file system does not support the last access time, this member is zero (0).
- ///
- /// The time this entry was last accessed.
- public DateTime LastAccessTime
- {
- get { return LastAccessTimeUtc.ToLocalTime(); }
- }
-
- #endregion // LastAccessTime
-
- #region LastAccessTimeUtc
-
- /// Gets the time, in coordinated universal time (UTC), this entry was last accessed.
- /// For a file, the structure specifies the last time that a file is read from or written to.
- /// For a directory, the structure specifies when the directory is created.
- /// For both files and directories, the specified date is correct, but the time of day is always set to midnight.
- /// If the underlying file system does not support the last access time, this member is zero (0).
- ///
- /// The time, in coordinated universal time (UTC), this entry was last accessed.
- public DateTime LastAccessTimeUtc { get; private set; }
-
- #endregion // LastAccessTimeUtc
-
- #region LastWriteTime
-
- /// Gets the time this entry was last modified.
- /// For a file, the structure specifies the last time that a file is written to.
- /// For a directory, the structure specifies when the directory is created.
- /// If the underlying file system does not support the last access time, this member is zero (0).
- ///
- /// The time this entry was last modified.
- public DateTime LastWriteTime
- {
- get { return LastWriteTimeUtc.ToLocalTime(); }
- }
-
- #endregion // LastWriteTime
-
- #region LastWriteTimeUtc
-
- /// Gets the time, in coordinated universal time (UTC), this entry was last modified.
- /// For a file, the structure specifies the last time that a file is written to.
- /// For a directory, the structure specifies when the directory is created.
- /// If the underlying file system does not support the last access time, this member is zero (0).
- ///
- /// The time, in coordinated universal time (UTC), this entry was last modified.
- public DateTime LastWriteTimeUtc { get; private set; }
-
- #endregion // LastWriteTimeUtc
-
- #region VolumeSerialNumber
-
- /// Gets the serial number of the volume that contains a file.
- /// The serial number of the volume that contains a file.
- public int VolumeSerialNumber { get; private set; }
-
- #endregion // VolumeSerialNumber
-
- #region FileSize
-
- /// Gets the size of the file.
- /// The size of the file.
- public long FileSize { get; private set; }
-
- #endregion // FileSize
-
- #region NumberOfLinks
-
- /// Gets the number of links to this file. For the FAT file system this member is always 1. For the NTFS file system, it can be more than 1.
- /// The number of links to this file.
- public int NumberOfLinks { get; private set; }
-
- #endregion // NumberOfLinks
-
- #region FileIndex
-
- ///
- /// Gets the unique identifier associated with the file. The identifier and the volume serial number uniquely identify a
- /// file on a single computer. To determine whether two open handles represent the same file, combine the identifier
- /// and the volume serial number for each file and compare them.
- ///
- /// The unique identifier of the file.
- public long FileIndex { get; private set; }
-
- #endregion // FileIndex
-
- #endregion // Properties
- }
-
- #endregion // ByHandleFileInfo
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs b/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs
deleted file mode 100644
index 035d52b..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- internal static partial class NativeMethods
- {
- /// Controls whether the system will handle the specified types of serious errors or whether the process will handle them.
- /// Minimum supported client: Windows 2000 Professional
- /// Minimum supported server: Windows 2000 Server
- public sealed class ChangeErrorMode : IDisposable
- {
- private readonly ErrorMode _oldMode;
-
- /// ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups.
- /// One of the values.
- public ChangeErrorMode(ErrorMode mode)
- {
- if (IsAtLeastWindows7)
- SetThreadErrorMode(mode, out _oldMode);
- else
- _oldMode = SetErrorMode(mode);
- }
-
- void IDisposable.Dispose()
- {
- ErrorMode oldMode;
-
- if (IsAtLeastWindows7)
- SetThreadErrorMode(_oldMode, out oldMode);
- else
- SetErrorMode(_oldMode);
- }
- }
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs b/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs
deleted file mode 100644
index 4e62e64..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Callback used by CopyFileXxx and MoveFileXxx to report progress about the copy/move operation.
- public delegate CopyMoveProgressResult CopyMoveProgressRoutine(long totalFileSize, long totalBytesTransferred, long streamSize, long streamBytesTransferred, int streamNumber, CopyMoveProgressCallbackReason callbackReason, object userData);
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs b/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs
deleted file mode 100644
index db216e1..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Class for CopyMoveResult that contains the results for the Copy or Move action.
- public sealed class CopyMoveResult
- {
- /// Create a CopyMoveResult class instance for the Copy or Move action.
- /// Indicates the source file or directory.
- /// Indicates the destination file or directory.
- /// Indicates if the action was canceled.
- /// The error code encountered during the Copy or Move action.
- public CopyMoveResult(string source, string destination, bool isCanceled, int errorCode)
- {
- Source = source;
- Destination = destination;
- IsCanceled = isCanceled;
- ErrorCode = errorCode;
- }
-
-
- /// The error code encountered during the Copy or Move action.
- /// 0 (zero) indicates success.
- public int ErrorCode { get; internal set; }
-
-
- /// When true indicates that the Copy or Move action was canceled.
- /// when the Copy/Move action was canceled. Otherwise .
- public bool IsCanceled { get; internal set; }
-
-
- /// Indicates the source file or directory.
- public string Source { get; private set; }
-
-
- /// Indicates the destination file or directory.
- public string Destination { get; private set; }
-
-
- /// The total number of folders copied.
- public long TotalFolders { get; internal set; }
-
-
- /// The total number of files copied.
- public long TotalFiles { get; internal set; }
-
-
- /// The total number of bytes copied.
- public long TotalBytes { get; internal set; }
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Device.cs b/FolderMonitor/AlphaFS/Filesystem/Device.cs
deleted file mode 100644
index 0d3318b..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Device.cs
+++ /dev/null
@@ -1,459 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Alphaleonis.Win32.Network;
-using Microsoft.Win32.SafeHandles;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-using System.Text;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Provides static methods to retrieve device resource information from a local or remote host.
- public static class Device
- {
- #region EnumerateDevices
-
- /// Enumerates all available devices on the local host.
- /// instances of type from the local host.
- /// One of the devices.
- [SecurityCritical]
- public static IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
- {
- return EnumerateDevices(null, deviceGuid);
- }
-
- /// Enumerates all available devices of type on the local or remote host.
- /// instances of type for the specified .
- /// The name of the local or remote host on which the device resides. refers to the local host.
- /// One of the devices.
- [SecurityCritical]
- public static IEnumerable EnumerateDevices(string hostName, DeviceGuid deviceGuid)
- {
- return EnumerateDevicesCore(null, hostName, deviceGuid);
- }
-
- #endregion // EnumerateDevices
-
- #region Internal Methods
-
- #region EnumerateDevicesCore
-
- /// Enumerates all available devices on the local or remote host.
- [SecurityCritical]
- internal static IEnumerable EnumerateDevicesCore(SafeHandle safeHandle, string hostName, DeviceGuid deviceInterfaceGuid)
- {
- var callerHandle = safeHandle != null;
- var deviceGuid = new Guid(Utils.GetEnumDescription(deviceInterfaceGuid));
-
-
- // CM_Connect_Machine()
- // MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
- // You cannot access remote machines when running on these versions of Windows.
- // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
-
- SafeCmConnectMachineHandle safeMachineHandle;
- var lastError = NativeMethods.CM_Connect_Machine(Path.LocalToUncCore(Host.GetUncName(hostName), false, false, false), out safeMachineHandle);
-
- if (safeMachineHandle != null && safeMachineHandle.IsInvalid)
- {
- safeMachineHandle.Close();
- NativeError.ThrowException(lastError, Resources.Handle_Is_Invalid);
- }
-
- using (safeMachineHandle)
- {
- // Start at the "Root" of the device tree of the specified machine.
- if (!callerHandle)
- safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref deviceGuid, IntPtr.Zero, IntPtr.Zero,
- NativeMethods.SetupDiGetClassDevsExFlags.Present |
- NativeMethods.SetupDiGetClassDevsExFlags.DeviceInterface,
- IntPtr.Zero, hostName, IntPtr.Zero);
-
- if (safeHandle != null && safeHandle.IsInvalid)
- {
- safeHandle.Close();
- NativeError.ThrowException(Marshal.GetLastWin32Error(), Resources.Handle_Is_Invalid);
- }
-
-
- try
- {
- uint memberInterfaceIndex = 0;
- var deviceInterfaceData = CreateDeviceInterfaceDataInstance();
-
- // Start enumerating Device Interfaces.
- while (NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref deviceGuid, memberInterfaceIndex++, ref deviceInterfaceData))
- {
- lastError = Marshal.GetLastWin32Error();
- if (lastError != Win32Errors.NO_ERROR)
- NativeError.ThrowException(lastError, hostName);
-
-
- var deviceInfoData = CreateDeviceInfoDataInstance();
- var deviceInterfaceDetailData = GetDeviceInterfaceDetailDataInstance(safeHandle, deviceInterfaceData, deviceInfoData);
-
- // Get device interace details.
- if (!NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref deviceInterfaceData, ref deviceInterfaceDetailData, NativeMethods.DefaultFileBufferSize, IntPtr.Zero, ref deviceInfoData))
- {
- lastError = Marshal.GetLastWin32Error();
- if (lastError != Win32Errors.NO_ERROR)
- NativeError.ThrowException(lastError, hostName);
- }
-
- // Create DeviceInfo instance.
- // Set DevicePath property of DeviceInfo instance.
- var deviceInfo = new DeviceInfo(hostName) { DevicePath = deviceInterfaceDetailData.DevicePath };
-
-
- // Current InstanceId is at the "USBSTOR" level, so we
- // need up "move up" one level to get to the "USB" level.
- uint ptrPrevious;
-
- // CM_Get_Parent_Ex()
- // Note: Using this function to access remote machines is not supported
- // beginning with Windows 8 and Windows Server 2012, as this functionality has been removed.
- // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538615%28v=vs.85%29.aspx
-
- lastError = NativeMethods.CM_Get_Parent_Ex(out ptrPrevious, deviceInfoData.DevInst, 0, safeMachineHandle);
- if (lastError != Win32Errors.CR_SUCCESS)
- NativeError.ThrowException(lastError, hostName);
-
-
- // Now we get the InstanceID of the USB level device.
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize))
- {
- // CM_Get_Device_ID_Ex()
- // Note: Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012,
- // as this functionality has been removed.
- // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538411%28v=vs.85%29.aspx
-
- lastError = NativeMethods.CM_Get_Device_ID_Ex(deviceInfoData.DevInst, safeBuffer, (uint)safeBuffer.Capacity, 0, safeMachineHandle);
- if (lastError != Win32Errors.CR_SUCCESS)
- NativeError.ThrowException(lastError, hostName);
-
- // Add to instance.
- deviceInfo.InstanceId = safeBuffer.PtrToStringUni();
- }
-
- #region Get Registry Properties
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize))
- {
- uint regType;
- string dataString;
- var safeBufferCapacity = (uint) safeBuffer.Capacity;
-
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.BaseContainerId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- {
- dataString = safeBuffer.PtrToStringUni();
- if (!Utils.IsNullOrWhiteSpace(dataString))
- deviceInfo.BaseContainerId = new Guid(dataString);
- }
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.ClassGuid, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- {
- dataString = safeBuffer.PtrToStringUni();
- if (!Utils.IsNullOrWhiteSpace(dataString))
- deviceInfo.ClassGuid = new Guid(dataString);
- }
-
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Class, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.Class = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.CompatibleIds, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.CompatibleIds = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.DeviceDescription, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.DeviceDescription = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Driver, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.Driver = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.EnumeratorName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.EnumeratorName = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.FriendlyName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.FriendlyName = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.HardwareId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.HardwareId = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationInformation, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.LocationInformation = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationPaths, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.LocationPaths = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Manufacturer, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.Manufacturer = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.PhysicalDeviceObjectName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.PhysicalDeviceObjectName = safeBuffer.PtrToStringUni();
-
- if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Service, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero))
- deviceInfo.Service = safeBuffer.PtrToStringUni();
- }
-
- #endregion // Get Registry Properties
-
- yield return deviceInfo;
-
- // Get new structure instance.
- deviceInterfaceData = CreateDeviceInterfaceDataInstance();
- }
- }
- finally
- {
- // Handle is ours, dispose.
- if (!callerHandle && safeHandle != null)
- safeHandle.Close();
- }
- }
- }
-
- #endregion // EnumerateDevicesCore
-
- #region GetLinkTargetInfoCore
-
- /// Get information about the target of a mount point or symbolic link on an NTFS file system.
- [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Disposing is controlled.")]
- [SecurityCritical]
- internal static LinkTargetInfo GetLinkTargetInfoCore(SafeFileHandle safeHandle)
- {
- // Start with a large buffer to prevent a 2nd call.
- // MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
- uint bytesReturned = 4*NativeMethods.DefaultFileBufferSize;
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle((int) bytesReturned))
- {
- while (true)
- {
- // DeviceIoControlMethod.Buffered = 0,
- // DeviceIoControlFileDevice.FileSystem = 9
- // FsctlGetReparsePoint = (DeviceIoControlFileDevice.FileSystem << 16) | (42 << 2) | DeviceIoControlMethod.Buffered | (0 << 14)
-
- if (!NativeMethods.DeviceIoControl(safeHandle, ((9 << 16) | (42 << 2) | 0 | (0 << 14)), IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, out bytesReturned, IntPtr.Zero))
- {
- var lastError = Marshal.GetLastWin32Error();
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_MORE_DATA:
- case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
- if (safeBuffer.Capacity < bytesReturned)
- {
- safeBuffer.Close();
- break;
- }
-
- NativeError.ThrowException(lastError);
- break;
- }
- }
- else
- break;
- }
-
-
- var marshalReparseBuffer = (int) Marshal.OffsetOf(typeof(NativeMethods.ReparseDataBufferHeader), "data");
-
- var header = safeBuffer.PtrToStructure(0);
-
- var dataOffset = (int) (marshalReparseBuffer + (header.ReparseTag == ReparsePointTag.MountPoint
- ? Marshal.OffsetOf(typeof (NativeMethods.MountPointReparseBuffer), "data")
- : Marshal.OffsetOf(typeof (NativeMethods.SymbolicLinkReparseBuffer), "data")).ToInt64());
-
- var dataBuffer = new byte[bytesReturned - dataOffset];
-
-
- switch (header.ReparseTag)
- {
- case ReparsePointTag.MountPoint:
- var mountPoint = safeBuffer.PtrToStructure(marshalReparseBuffer);
-
- safeBuffer.CopyTo(dataOffset, dataBuffer, 0, dataBuffer.Length);
-
- return new LinkTargetInfo(
- Encoding.Unicode.GetString(dataBuffer, mountPoint.SubstituteNameOffset, mountPoint.SubstituteNameLength),
- Encoding.Unicode.GetString(dataBuffer, mountPoint.PrintNameOffset, mountPoint.PrintNameLength));
-
-
- case ReparsePointTag.SymLink:
- var symLink = safeBuffer.PtrToStructure(marshalReparseBuffer);
-
- safeBuffer.CopyTo(dataOffset, dataBuffer, 0, dataBuffer.Length);
-
- return new SymbolicLinkTargetInfo(
- Encoding.Unicode.GetString(dataBuffer, symLink.SubstituteNameOffset, symLink.SubstituteNameLength),
- Encoding.Unicode.GetString(dataBuffer, symLink.PrintNameOffset, symLink.PrintNameLength), symLink.Flags);
-
-
- default:
- throw new UnrecognizedReparsePointException();
- }
- }
- }
-
- #endregion // GetLinkTargetInfoCore
-
- #region ToggleCompressionCore
-
- /// Sets the NTFS compression state of a file or directory on a volume whose file system supports per-file and per-directory compression.
- /// Specifies that is a file or directory.
- /// The transaction.
- /// A path that describes a folder or file to compress or decompress.
- /// = compress, = decompress
- /// Indicates the format of the path parameter(s).
-
- [SecurityCritical]
- internal static void ToggleCompressionCore(bool isFolder, KernelTransaction transaction, string path, bool compress, PathFormat pathFormat)
- {
- using (var handle = File.CreateFileCore(transaction, path, isFolder ? ExtendedFileAttributes.BackupSemantics : ExtendedFileAttributes.Normal, null, FileMode.Open, FileSystemRights.Modify, FileShare.None, true, pathFormat))
- {
- // DeviceIoControlMethod.Buffered = 0,
- // DeviceIoControlFileDevice.FileSystem = 9
- // FsctlSetCompression = (DeviceIoControlFileDevice.FileSystem << 16) | (16 << 2) | DeviceIoControlMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14)
-
- // 0 = Decompress, 1 = Compress.
- InvokeIoControlUnknownSize(handle, ((9 << 16) | (16 << 2) | 0 | ((uint)(FileAccess.Read | FileAccess.Write) << 14)), (compress) ? 1 : 0);
- }
- }
-
- #endregion // ToggleCompressionCore
-
-
- #region Private
-
- #region CreateDeviceInfoDataInstance
-
- /// Builds a DeviceInfo Data structure.
- /// An initialized NativeMethods.SP_DEVINFO_DATA instance.
- [SecurityCritical]
- private static NativeMethods.SP_DEVINFO_DATA CreateDeviceInfoDataInstance()
- {
- var did = new NativeMethods.SP_DEVINFO_DATA();
- did.cbSize = (uint) Marshal.SizeOf(did);
-
- return did;
- }
-
- #endregion // CreateDeviceInfoDataInstance
-
- #region CreateDeviceInterfaceDataInstance
-
- /// Builds a Device Interface Data structure.
- /// An initialized NativeMethods.SP_DEVICE_INTERFACE_DATA instance.
- [SecurityCritical]
- private static NativeMethods.SP_DEVICE_INTERFACE_DATA CreateDeviceInterfaceDataInstance()
- {
- var did = new NativeMethods.SP_DEVICE_INTERFACE_DATA();
- did.cbSize = (uint) Marshal.SizeOf(did);
-
- return did;
- }
-
- #endregion // CreateDeviceInterfaceDataInstance
-
- #region GetDeviceInterfaceDetailDataInstance
-
- /// Builds a Device Interface Detail Data structure.
- /// An initialized NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA instance.
- [SecurityCritical]
- private static NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA GetDeviceInterfaceDetailDataInstance(SafeHandle safeHandle, NativeMethods.SP_DEVICE_INTERFACE_DATA deviceInterfaceData, NativeMethods.SP_DEVINFO_DATA deviceInfoData)
- {
- // Build a Device Interface Detail Data structure.
- var didd = new NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA
- {
- cbSize = (IntPtr.Size == 4) ? (uint) (Marshal.SystemDefaultCharSize + 4) : 8
- };
-
- // Get device interace details.
- if (!NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref deviceInterfaceData, ref didd, NativeMethods.DefaultFileBufferSize, IntPtr.Zero, ref deviceInfoData))
- {
- var lastError = Marshal.GetLastWin32Error();
- if (lastError != Win32Errors.NO_ERROR)
- NativeError.ThrowException(lastError);
- }
-
- return didd;
- }
-
- #endregion // GetDeviceInterfaceDetailDataInstance
-
- #region InvokeIoControlUnknownSize
-
- /// Repeatedly invokes InvokeIoControl with the specified input until enough memory has been allocated.
- [SecurityCritical]
- private static byte[] InvokeIoControlUnknownSize(SafeFileHandle handle, uint controlCode, TV input, uint increment = 128)
- {
- byte[] output;
- uint bytesReturned;
-
- var inputSize = (uint) Marshal.SizeOf(input);
- var outputLength = increment;
-
- do
- {
- output = new byte[outputLength];
- if (!NativeMethods.DeviceIoControl(handle, controlCode, input, inputSize, output, outputLength, out bytesReturned, IntPtr.Zero))
- {
- var lastError = Marshal.GetLastWin32Error();
- switch ((uint)lastError)
- {
- case Win32Errors.ERROR_MORE_DATA:
- case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
- outputLength += increment;
- break;
-
- default:
- NativeError.ThrowException(lastError);
- break;
- }
- }
- else
- break;
-
- } while (true);
-
- // Return the result
- if (output.Length == bytesReturned)
- return output;
-
- var res = new byte[bytesReturned];
- Array.Copy(output, res, bytesReturned);
-
- return res;
- }
-
- #endregion // InvokeIoControlUnknownSize
-
- #endregion // Private
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs
deleted file mode 100644
index 82e0946..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Alphaleonis.Win32.Network;
-using System;
-using System.Collections.Generic;
-using System.Security;
-using System.Security.Permissions;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Provides access to information of a device, on a local or remote host.
- [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
- [SerializableAttribute]
- [SecurityCritical]
- public sealed class DeviceInfo
- {
- #region Constructors
-
- /// Initializes a DeviceInfo class.
- [SecurityCritical]
- public DeviceInfo()
- {
- HostName = Host.GetUncName();
- }
-
- /// Initializes a DeviceInfo class.
- /// The DNS or NetBIOS name of the remote server. refers to the local host.
- [SecurityCritical]
- public DeviceInfo(string host)
- {
- HostName = Host.GetUncName(host).Replace(Path.UncPrefix, string.Empty);
- }
-
- #endregion // Constructors
-
-
- #region Methods
-
- /// Enumerates all available devices on the local host.
- /// One of the devices.
- /// instances of type from the local host.
- [SecurityCritical]
- public IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
- {
- return Device.EnumerateDevicesCore(null, HostName, deviceGuid);
- }
-
- #endregion // Methods
-
-
- #region Properties
-
- /// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode).
- public Guid BaseContainerId { get; internal set; }
-
-
- /// Represents the name of the device setup class that a device instance belongs to.
- public string Class { get; internal set; }
-
-
- /// Represents the of the device setup class that a device instance belongs to.
- public Guid ClassGuid { get; internal set; }
-
-
- /// Represents the list of compatible identifiers for a device instance.
- public string CompatibleIds { get; internal set; }
-
-
- /// Represents a description of a device instance.
- public string DeviceDescription { get; internal set; }
-
-
- /// The device interface path.
- public string DevicePath { get; internal set; }
-
-
- /// Represents the registry entry name of the driver key for a device instance.
- public string Driver { get; internal set; }
-
-
- /// Represents the name of the enumerator for a device instance.
- public string EnumeratorName { get; internal set; }
-
-
- /// Represents the friendly name of a device instance.
- public string FriendlyName { get; internal set; }
-
-
- /// Represents the list of hardware identifiers for a device instance.
- public string HardwareId { get; internal set; }
-
-
- /// The host name that was passed to the class constructor.
- public string HostName { get; internal set; }
-
-
- /// Gets the instance Id of the device.
- public string InstanceId { get; internal set; }
-
-
- /// Represents the bus-specific physical location of a device instance.
- public string LocationInformation { get; internal set; }
-
-
- /// Represents the location of a device instance in the device tree.
- public string LocationPaths { get; internal set; }
-
-
- /// Represents the name of the manufacturer of a device instance.
- public string Manufacturer { get; internal set; }
-
-
- /// Encapsulates the physical device location information provided by a device's firmware to Windows.
- public string PhysicalDeviceObjectName { get; internal set; }
-
-
- /// Represents the name of the service that is installed for a device instance.
- public string Service { get; internal set; }
-
- #endregion // Properties
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs
deleted file mode 100644
index 13fb15f..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs
+++ /dev/null
@@ -1,484 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region Compress
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- /// This will only compress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to compress.
- [SecurityCritical]
- public static void Compress(string path)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- /// This will only compress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to compress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Compress(string path, PathFormat pathFormat)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, pathFormat);
- }
-
-
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to compress.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static void Compress(string path, DirectoryEnumerationOptions options)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to compress.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Compress(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, true, pathFormat);
- }
-
- #region Transactional
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- /// This will only compress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to compress.
- [SecurityCritical]
- public static void CompressTransacted(KernelTransaction transaction, string path)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- /// This will only compress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to compress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void CompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, pathFormat);
- }
-
-
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to compress.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Compresses a directory using NTFS compression.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to compress.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, true, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Compress
-
- #region Decompress
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- /// This will only decompress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decompress.
- [SecurityCritical]
- public static void Decompress(string path)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- /// This will only decompress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decompress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Decompress(string path, PathFormat pathFormat)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decompress.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static void Decompress(string path, DirectoryEnumerationOptions options)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decompress.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Decompress(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, false, pathFormat);
- }
-
- #region Transactional
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- /// This will only decompress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to decompress.
- [SecurityCritical]
- public static void DecompressTransacted(KernelTransaction transaction, string path)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- /// This will only decompress the root items (non recursive).
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to decompress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DecompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to decompress.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static void DecompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Decompresses an NTFS compressed directory.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to decompress.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DecompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, false, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Decompress
-
- #region DisableCompression
-
- /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it.
- /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path to a directory to decompress.
- [SecurityCritical]
- public static void DisableCompression(string path)
- {
- Device.ToggleCompressionCore(true, null, path, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it.
- /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path to a directory to decompress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DisableCompression(string path, PathFormat pathFormat)
- {
- Device.ToggleCompressionCore(true, null, path, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it.
- /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path to a directory to decompress.
- [SecurityCritical]
- public static void DisableCompressionTransacted(KernelTransaction transaction, string path)
- {
- Device.ToggleCompressionCore(true, transaction, path, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it.
- /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// Indicates the format of the path parameter(s).
- /// A path to a directory to decompress.
- [SecurityCritical]
- public static void DisableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- Device.ToggleCompressionCore(true, transaction, path, false, pathFormat);
- }
-
- #endregion // DisableCompression
-
- #region EnableCompression
-
- /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it.
- /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path to a directory to compress.
- [SecurityCritical]
- public static void EnableCompression(string path)
- {
- Device.ToggleCompressionCore(true, null, path, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it.
- /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path to a directory to compress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void EnableCompression(string path, PathFormat pathFormat)
- {
- Device.ToggleCompressionCore(true, null, path, true, pathFormat);
- }
-
-
-
- /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it.
- /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path to a directory to compress.
- [SecurityCritical]
- public static void EnableCompressionTransacted(KernelTransaction transaction, string path)
- {
- Device.ToggleCompressionCore(true, transaction, path, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it.
- /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path to a directory to compress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void EnableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- Device.ToggleCompressionCore(true, transaction, path, true, pathFormat);
- }
-
- #endregion // EnableCompression
-
- #region Internal Methods
-
- /// Compress/decompress Non-/Transacted files/directories.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// A path that describes a directory to compress.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// compress, when decompress.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void CompressDecompressCore(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, bool compress, PathFormat pathFormat)
- {
- string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
-
- // Process directories and files.
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, pathLp, searchPattern, options | DirectoryEnumerationOptions.AsLongPath, PathFormat.LongFullPath))
- Device.ToggleCompressionCore(true, transaction, fsei, compress, PathFormat.LongFullPath);
-
- // Compress the root directory, the given path.
- Device.ToggleCompressionCore(true, transaction, pathLp, compress, PathFormat.LongFullPath);
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs
deleted file mode 100644
index a0622ed..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs
+++ /dev/null
@@ -1,978 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region Copy
-
- // .NET: Directory class does not contain the Copy() method.
- // Mimic .NET File.Copy() methods.
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, .
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, bool overwrite)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, bool overwrite, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, .
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, bool overwrite)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed.
- ///
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, bool overwrite, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Copy
-
-
- #region Copy (CopyOptions)
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been copied. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been copied. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been copied. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Copies a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// Option is recommended for very large file transfers.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Copy action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been copied. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Copy (CopyOptions)
-
-
- #region Move
-
- #region .NET
-
- /// Moves a file or a directory and its contents to a new location.
- ///
- /// This method does not work across disk volumes.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location.
- ///
- /// This method does not work across disk volumes.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, pathFormat);
- }
-
-
-
- #region Transactional
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location.
- ///
- /// This method does not work across disk volumes.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location.
- ///
- /// This method does not work across disk volumes.
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Move
-
-
- #region Move (MoveOptions)
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been moved. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been moved. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat)
- {
- return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, null, null, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, null, null, null, pathFormat);
- }
-
-
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been moved. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- /// A class with the status of the Move action.
- ///
- /// This method does not work across disk volumes unless contains .
- /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
- /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
- ///
- ///
- /// A class with details of the Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be moved. This parameter can be .
- /// A callback function that is called each time another portion of the directory has been moved. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat)
- {
- return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, pathFormat);
- }
-
- #endregion // Transactional
-
- #endregion // Move (MoveOptions)
-
-
- #region Internal Methods
-
- /// Copy/move a Non-/Transacted file or directory including its children to a new location,
- /// or can be specified,
- /// and the possibility of notifying the application of its progress through a callback function.
- ///
- /// Option is recommended for very large file transfers.
- /// You cannot use the Move method to overwrite an existing file, unless contains .
- /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an IOException.
- ///
- ///
- /// A class with the status of the Copy or Move action.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The source directory path.
- /// The destination directory path.
- /// that specify how the directory is to be copied. This parameter can be .
- /// that specify how the directory is to be moved. This parameter can be .
- /// A callback function that is called each time another portion of the file has been copied/moved. This parameter can be .
- /// The argument to be passed to the callback function. This parameter can be .
- ///
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SecurityCritical]
- internal static CopyMoveResult CopyMoveCore(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions? copyOptions, MoveOptions? moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat)
- {
- #region Setup
-
- var sourcePathLp = sourcePath;
- var destinationPathLp = destinationPath;
- var emulateMove = false;
-
- // Determine Copy or Move action.
- var isCopy = File.DetermineIsCopy(copyOptions, moveOptions);
- var isMove = !isCopy;
-
- var cmr = copyMoveResult ?? new CopyMoveResult(sourcePath, destinationPath, false, (int) Win32Errors.ERROR_SUCCESS);
-
-
- if (pathFormat != PathFormat.LongFullPath)
- {
- Path.CheckSupportedPathFormat(sourcePathLp, true, true);
- Path.CheckSupportedPathFormat(destinationPathLp, true, true);
-
-
- // MSDN: .NET 4+ Trailing spaces are removed from the end of the path parameters before moving the directory.
- // TrimEnd() is also applied for AlphaFS implementation of method Directory.Copy(), .NET does not have this method.
-
- const GetFullPathOptions fullPathOptions = GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator;
-
- sourcePathLp = Path.GetExtendedLengthPathCore(transaction, sourcePath, pathFormat, fullPathOptions);
- destinationPathLp = Path.GetExtendedLengthPathCore(transaction, destinationPath, pathFormat, fullPathOptions);
-
-
- // MSDN: .NET3.5+: IOException: The sourceDirName and destDirName parameters refer to the same file or directory.
- if (sourcePathLp.Equals(destinationPathLp, StringComparison.OrdinalIgnoreCase))
- NativeError.ThrowException(Win32Errors.ERROR_SAME_DRIVE, destinationPathLp);
-
-
- // Execute once only.
- if (isMove)
- {
- // Compare the root part of both paths.
- var equalRootPaths = Path.GetPathRoot(sourcePathLp, false).Equals(Path.GetPathRoot(destinationPathLp, false), StringComparison.OrdinalIgnoreCase);
-
- // Method Volume.IsSameVolume() returns true when both paths refer to the same volume, even if one of the paths is a UNC path.
- // For example, src = C:\TempSrc and dst = \\localhost\C$\TempDst
- var isSameVolume = equalRootPaths || Volume.IsSameVolume(sourcePathLp, destinationPathLp);
-
- isMove = isSameVolume && equalRootPaths;
-
-
- if (!isMove)
- {
- // A Move() can be emulated by using Copy() and Delete(), but only if the CopyAllowed flag is set.
- isMove = ((MoveOptions) moveOptions & MoveOptions.CopyAllowed) != 0;
-
- // MSDN: .NET3.5+: IOException: An attempt was made to move a directory to a different volume.
- if (!isMove)
- NativeError.ThrowException(Win32Errors.ERROR_NOT_SAME_DEVICE, sourcePathLp, destinationPathLp);
- }
-
-
- // The NativeMethod.MoveFileXxx() methods fail when:
- // - A directory is being moved;
- // - One of the paths is a UNC path, even though both paths refer to the same volume.
- // For example, src = C:\TempSrc and dst = \\localhost\C$\TempDst
- if (isMove)
- {
- var srcIsUncPath = Path.IsUncPathCore(sourcePathLp, false, false);
- var dstIsUncPath = Path.IsUncPathCore(destinationPathLp, false, false);
-
- isMove = srcIsUncPath && dstIsUncPath;
- if (!isMove)
- isMove = !srcIsUncPath && !dstIsUncPath;
- }
-
-
- isMove = isMove && isSameVolume && equalRootPaths;
-
-
- // Emulate Move().
- if (!isMove)
- {
- emulateMove = true;
-
- moveOptions = null;
-
- isCopy = true;
- copyOptions = CopyOptions.FailIfExists;
- }
- }
- }
-
- #endregion // Setup
-
-
- #region Copy
-
- if (isCopy)
- {
- CreateDirectoryCore(transaction, destinationPathLp, null, null, false, PathFormat.LongFullPath);
-
- var dirs = new Queue(1000);
- dirs.Enqueue(sourcePathLp);
-
- while (dirs.Count > 0)
- {
- var srcLp = dirs.Dequeue();
- var dstLp = srcLp.Replace(sourcePathLp, destinationPathLp);
-
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, srcLp, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath))
- {
- var newDestinationPathLp = Path.CombineCore(false, dstLp, fsei.FileName);
-
- if (fsei.IsDirectory)
- {
- CreateDirectoryCore(transaction, newDestinationPathLp, null, null, false, PathFormat.LongFullPath);
-
- dirs.Enqueue(fsei.LongFullPath);
- cmr.TotalFolders++;
-
- continue;
- }
-
-
- cmr = File.CopyMoveCore(false, transaction, fsei.LongFullPath, newDestinationPathLp, false, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath);
-
- if (cmr.ErrorCode == Win32Errors.ERROR_SUCCESS)
- {
- cmr.TotalFiles++;
- cmr.TotalBytes += fsei.FileSize;
-
- // Remove the folder or file when copying was successful.
- if (emulateMove)
- {
- if (fsei.IsDirectory)
- DeleteDirectoryCore(fsei, transaction, null, true, true, true, PathFormat.LongFullPath);
-
- else
- File.DeleteFileCore(transaction, fsei.LongFullPath, true, PathFormat.LongFullPath);
- }
- }
-
-
- if (cmr.IsCanceled)
- return cmr;
- }
- }
-
- // Remove source folder.
- if (emulateMove && cmr.ErrorCode == Win32Errors.ERROR_SUCCESS)
- DeleteDirectoryCore(null, transaction, sourcePathLp, true, true, true, PathFormat.LongFullPath);
- }
-
- #endregion // Copy
-
-
- #region Move
-
- else
- {
- // MoveOptions.ReplaceExisting: This value cannot be used if lpNewFileName or lpExistingFileName names a directory.
- if (((MoveOptions) moveOptions & MoveOptions.ReplaceExisting) != 0)
- DeleteDirectoryCore(null, transaction, destinationPathLp, true, true, true, PathFormat.LongFullPath);
-
-
- // Moves a file or directory, including its children.
- // Copies an existing directory, including its children to a new directory.
- cmr = File.CopyMoveCore(true, transaction, sourcePathLp, destinationPathLp, false, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath);
- }
-
- #endregion // Move
-
-
- return isMove ? null : cmr;
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs
deleted file mode 100644
index 9bbb8af..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory path.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static long CountFileSystemObjects(string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath).Count();
- }
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory path.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static long CountFileSystemObjects(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat).Count();
- }
-
-
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory path.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static long CountFileSystemObjects(string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).Count();
- }
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory path.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static long CountFileSystemObjects(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat).Count();
- }
-
- #region Transactional
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory path.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath).Count();
- }
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory path.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat).Count();
- }
-
-
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory path.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).Count();
- }
-
- /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory.
- /// The counted number of file system objects.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory path.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat).Count();
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
deleted file mode 100644
index 4637e2c..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
+++ /dev/null
@@ -1,800 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Creates all directories and subdirectories in the specified path unless they already exist.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path)
- {
- return CreateDirectoryCore(null, path, null, null, false, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, null, null, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, bool compress)
- {
- return CreateDirectoryCore(null, path, null, null, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, null, null, compress, pathFormat);
- }
-
-
-
- /// Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The access control to apply to the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity)
- {
- return CreateDirectoryCore(null, path, null, directorySecurity, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The access control to apply to the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, null, directorySecurity, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, bool compress)
- {
- return CreateDirectoryCore(null, path, null, directorySecurity, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, null, directorySecurity, compress, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath)
- {
- return CreateDirectoryCore(null, path, templatePath, null, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, templatePath, null, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, bool compress)
- {
- return CreateDirectoryCore(null, path, templatePath, null, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, templatePath, null, compress, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity)
- {
- return CreateDirectoryCore(null, path, templatePath, directorySecurity, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, templatePath, directorySecurity, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, bool compress)
- {
- return CreateDirectoryCore(null, path, templatePath, directorySecurity, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(null, path, templatePath, directorySecurity, compress, pathFormat);
- }
-
- #region Transactional
-
- /// Creates all directories and subdirectories in the specified path unless they already exist.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path)
- {
- return CreateDirectoryCore(transaction, path, null, null, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, null, null, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, bool compress)
- {
- return CreateDirectoryCore(transaction, path, null, null, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, null, null, compress, pathFormat);
- }
-
-
-
- /// Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The access control to apply to the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity)
- {
- return CreateDirectoryCore(transaction, path, null, directorySecurity, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The access control to apply to the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, null, directorySecurity, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, bool compress)
- {
- return CreateDirectoryCore(transaction, path, null, directorySecurity, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, null, directorySecurity, compress, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath)
- {
- return CreateDirectoryCore(transaction, path, templatePath, null, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, templatePath, null, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, bool compress)
- {
- return CreateDirectoryCore(transaction, path, templatePath, null, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, templatePath, null, compress, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity)
- {
- return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, bool compress)
- {
- return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, compress, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security.
- /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory.
- /// The access control to apply to the directory.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- [SecurityCritical]
- public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat)
- {
- return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, compress, pathFormat);
- }
-
- #endregion // Transactional
-
- #region Internal Methods
-
- /// Creates a new directory with the attributes of a specified template directory (if one is specified).
- /// If the underlying file system supports security on files and directories, the function applies the specified security descriptor to the new directory.
- /// The new directory retains the other attributes of the specified template directory.
- ///
- ///
- /// Returns an object that represents the directory at the specified path.
- /// This object is returned regardless of whether a directory at the specified path already exists.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to create.
- /// The path of the directory to use as a template when creating the new directory. May be to indicate that no template should be used.
- /// The access control to apply to the directory, may be null.
- /// When compresses the directory.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SecurityCritical]
- internal static DirectoryInfo CreateDirectoryCore(KernelTransaction transaction, string path, string templatePath, ObjectSecurity directorySecurity, bool compress, PathFormat pathFormat)
- {
- bool fullCheck = pathFormat == PathFormat.RelativePath;
-
- Path.CheckSupportedPathFormat(path, fullCheck, fullCheck);
- Path.CheckSupportedPathFormat(templatePath, fullCheck, fullCheck);
-
-
- string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator);
-
- // Return DirectoryInfo instance if the directory specified by path already exists.
- if (File.ExistsCore(true, transaction, pathLp, PathFormat.LongFullPath))
- return new DirectoryInfo(transaction, pathLp, PathFormat.LongFullPath);
-
- // MSDN: .NET 3.5+: IOException: The directory specified by path is a file or the network name was not found.
- if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath))
- NativeError.ThrowException(Win32Errors.ERROR_ALREADY_EXISTS, pathLp);
-
-
- string templatePathLp = Utils.IsNullOrWhiteSpace(templatePath)
- ? null
- : Path.GetExtendedLengthPathCore(transaction, templatePath, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator);
-
-
- #region Construct Full Path
-
- string longPathPrefix = Path.IsUncPathCore(path, false, false) ? Path.LongPathUncPrefix : Path.LongPathPrefix;
- path = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false);
-
- int length = path.Length;
- if (length >= 2 && Path.IsDVsc(path[length - 1], false))
- --length;
-
- int rootLength = Path.GetRootLength(path, false);
- if (length == 2 && Path.IsDVsc(path[1], false))
- throw new ArgumentException(Resources.Cannot_Create_Directory, path);
-
-
- // Check if directories are missing.
- var list = new Stack(100);
-
- if (length > rootLength)
- {
- for (int index = length - 1; index >= rootLength; --index)
- {
- string path1 = path.Substring(0, index + 1);
- string path2 = longPathPrefix + path1.TrimStart('\\');
-
- if (!File.ExistsCore(true, transaction, path2, PathFormat.LongFullPath))
- list.Push(path2);
-
- while (index > rootLength && !Path.IsDVsc(path[index], false))
- --index;
- }
- }
-
- #endregion // Construct Full Path
-
-
- // Directory security.
- using (var securityAttributes = new Security.NativeMethods.SecurityAttributes(directorySecurity))
- {
- // Create the directory paths.
- while (list.Count > 0)
- {
- string folderLp = list.Pop();
-
- // In the ANSI version of this function, the name is limited to 248 characters.
- // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
- // 2013-01-13: MSDN confirms LongPath usage.
-
- if (!(transaction == null || !NativeMethods.IsAtLeastWindowsVista
- ? (templatePathLp == null
- ? NativeMethods.CreateDirectory(folderLp, securityAttributes)
- : NativeMethods.CreateDirectoryEx(templatePathLp, folderLp, securityAttributes))
- : NativeMethods.CreateDirectoryTransacted(templatePathLp, folderLp, securityAttributes, transaction.SafeHandle)))
- {
- int lastError = Marshal.GetLastWin32Error();
-
- switch ((uint) lastError)
- {
- // MSDN: .NET 3.5+: If the directory already exists, this method does nothing.
- // MSDN: .NET 3.5+: IOException: The directory specified by path is a file.
- case Win32Errors.ERROR_ALREADY_EXISTS:
- if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath))
- NativeError.ThrowException(lastError, pathLp);
-
- if (File.ExistsCore(false, transaction, folderLp, PathFormat.LongFullPath))
- NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, folderLp);
- break;
-
- case Win32Errors.ERROR_BAD_NET_NAME:
- NativeError.ThrowException(lastError, pathLp);
- break;
-
- case Win32Errors.ERROR_DIRECTORY:
- // MSDN: .NET 3.5+: NotSupportedException: path contains a colon character (:) that is not part of a drive label ("C:\").
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Unsupported_Path_Format, path));
-
- default:
- NativeError.ThrowException(lastError, folderLp);
- break;
- }
- }
-
- else if (compress)
- Device.ToggleCompressionCore(true, transaction, folderLp, true, PathFormat.LongFullPath);
- }
-
- return new DirectoryInfo(transaction, pathLp, PathFormat.LongFullPath);
- }
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs
deleted file mode 100644
index df427f3..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- ///
- /// Gets the current working directory of the application.
- ///
- /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names.
- /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process,
- /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value.
- /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread,
- /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads.
- /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported.
- ///
- ///
- /// The path of the current working directory without a trailing directory separator.
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate"), SecurityCritical]
- public static string GetCurrentDirectory()
- {
- var nameBuffer = new StringBuilder(NativeMethods.MaxPathUnicode);
-
- // SetCurrentDirectory()
- // In the ANSI version of this function, the name is limited to 248 characters.
- // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
- // 2016-09-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
-
- var folderNameLength = NativeMethods.GetCurrentDirectory((uint) nameBuffer.Capacity, nameBuffer);
- var lastError = Marshal.GetLastWin32Error();
-
- if (folderNameLength == 0)
- NativeError.ThrowException(lastError);
-
- if (folderNameLength > NativeMethods.MaxPathUnicode)
- throw new PathTooLongException(string.Format(CultureInfo.InvariantCulture, "Path is greater than {0} characters: {1}", NativeMethods.MaxPathUnicode, folderNameLength));
-
- return nameBuffer.ToString();
- }
-
-
- ///
- /// Sets the application's current working directory to the specified directory.
- ///
- /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names.
- /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process,
- /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value.
- /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread,
- /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads.
- /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported.
- ///
- ///
- /// The path to which the current working directory is set.
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
- [SecurityCritical]
- public static void SetCurrentDirectory(string path)
- {
- SetCurrentDirectory(path, PathFormat.RelativePath);
- }
-
-
- ///
- /// Sets the application's current working directory to the specified directory.
- ///
- /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names.
- /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process,
- /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value.
- /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread,
- /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads.
- /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported.
- ///
- ///
- /// The path to which the current working directory is set.
- /// Indicates the format of the path parameter.
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
- [SecurityCritical]
- public static void SetCurrentDirectory(string path, PathFormat pathFormat)
- {
- if (Utils.IsNullOrWhiteSpace(path))
- throw new ArgumentNullException("path");
-
- var fullCheck = pathFormat == PathFormat.RelativePath;
- Path.CheckSupportedPathFormat(path, fullCheck, fullCheck);
- var pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.AddTrailingDirectorySeparator);
-
- if (pathFormat == PathFormat.FullPath)
- pathLp = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false);
-
-
- // SetCurrentDirectory()
- // In the ANSI version of this function, the name is limited to 248 characters.
- // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
- // 2016-09-29: MSDN confirms LongPath usage starting with Windows 10, version 1607.
-
- if (!NativeMethods.SetCurrentDirectory(pathLp))
- NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp);
- }
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
deleted file mode 100644
index de87b48..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
+++ /dev/null
@@ -1,422 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Deletes an empty directory from a specified path.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the empty directory to remove. This directory must be writable and empty.
- [SecurityCritical]
- public static void Delete(string path)
- {
- DeleteDirectoryCore(null, null, path, false, false, false, PathFormat.RelativePath);
- }
-
- /// Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- [SecurityCritical]
- public static void Delete(string path, bool recursive)
- {
- DeleteDirectoryCore(null, null, path, recursive, false, false, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Deletes an empty directory from a specified path.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the empty directory to remove. This directory must be writable and empty.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Delete(string path, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, null, path, false, false, false, pathFormat);
- }
-
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Delete(string path, bool recursive, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, null, path, recursive, false, false, pathFormat);
- }
-
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// overrides read only of files and directories.
- [SecurityCritical]
- public static void Delete(string path, bool recursive, bool ignoreReadOnly)
- {
- DeleteDirectoryCore(null, null, path, recursive, ignoreReadOnly, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// overrides read only of files and directories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Delete(string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, null, path, recursive, ignoreReadOnly, false, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Deletes an empty directory from a specified path.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the empty directory to remove. This directory must be writable and empty.
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path)
- {
- DeleteDirectoryCore(null, transaction, path, false, false, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes an empty directory from a specified path.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the empty directory to remove. This directory must be writable and empty.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, transaction, path, false, false, false, pathFormat);
- }
-
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive)
- {
- DeleteDirectoryCore(null, transaction, path, recursive, false, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, transaction, path, recursive, false, false, pathFormat);
- }
-
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// overrides read only of files and directories.
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly)
- {
- DeleteDirectoryCore(null, transaction, path, recursive, ignoreReadOnly, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove.
- /// to remove directories, subdirectories, and files in . otherwise.
- /// overrides read only of files and directories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat)
- {
- DeleteDirectoryCore(null, transaction, path, recursive, ignoreReadOnly, false, pathFormat);
- }
-
- #endregion // Transactional
-
-
- #region Internal Methods
-
- /// Deletes the specified directory and, if indicated, any subdirectories in the directory.
- /// The RemoveDirectory function marks a directory for deletion on close. Therefore, the directory is not removed until the last handle to the directory is closed.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// A FileSystemEntryInfo instance. Use either or , not both.
- /// The transaction.
- /// The name of the directory to remove. Use either or , not both.
- /// to remove all files and subdirectories recursively; otherwise only the top level empty directory.
- /// overrides read only attribute of files and directories.
- /// When does not throw an Exception when the directory does not exist.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SecurityCritical]
- internal static void DeleteDirectoryCore(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool continueOnNotFound, PathFormat pathFormat)
- {
- #region Setup
-
- if (fsEntryInfo == null)
- {
- // MSDN: .NET 3.5+: DirectoryNotFoundException:
- // Path does not exist or could not be found.
- // Path refers to a file instead of a directory.
- // The specified path is invalid (for example, it is on an unmapped drive).
-
- if (pathFormat == PathFormat.RelativePath)
- Path.CheckSupportedPathFormat(path, true, true);
-
- fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator), continueOnNotFound, pathFormat);
-
- if (fsEntryInfo == null)
- return;
- }
-
- #endregion // Setup
-
-
- // Do not follow mount points nor symbolic links, but do delete the reparse point itself.
- // If directory is reparse point, disable recursion.
-
- if (recursive && !fsEntryInfo.IsReparsePoint)
- {
- var dirs = new Stack(1000);
-
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders | DirectoryEnumerationOptions.Recursive, PathFormat.LongFullPath))
- {
- if (fsei.IsDirectory)
- {
- // Check to see if this is a mount point, and unmount it.
- // Now it is safe to delete the actual directory.
- if (fsei.IsMountPoint)
- Volume.DeleteVolumeMountPointCore(fsei.LongFullPath, false);
-
- dirs.Push(fsei.LongFullPath);
- }
-
- else
- File.DeleteFileCore(transaction, fsei.LongFullPath, ignoreReadOnly, PathFormat.LongFullPath);
- }
-
-
- while (dirs.Count > 0)
- DeleteDirectoryCore(transaction, dirs.Pop(), ignoreReadOnly, continueOnNotFound);
- }
-
-
- // Check to see if this is a mount point, and unmount it.
- // Now it is safe to delete the actual directory.
- if (fsEntryInfo.IsMountPoint)
- Volume.DeleteVolumeMountPointCore(fsEntryInfo.LongFullPath, false);
-
- DeleteDirectoryCore(transaction, fsEntryInfo.LongFullPath, ignoreReadOnly, continueOnNotFound);
- }
-
-
- private static void DeleteDirectoryCore(KernelTransaction transaction, string pathLp, bool ignoreReadOnly, bool continueOnNotFound)
- {
- startRemoveDirectory:
-
- var success = transaction == null || !NativeMethods.IsAtLeastWindowsVista
-
- // RemoveDirectory() / RemoveDirectoryTransacted()
- // In the ANSI version of this function, the name is limited to MAX_PATH characters.
- // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
- // 2014-09-09: MSDN confirms LongPath usage.
-
- // RemoveDirectory on a symbolic link will remove the link itself.
-
- ? NativeMethods.RemoveDirectory(pathLp)
- : NativeMethods.RemoveDirectoryTransacted(pathLp, transaction.SafeHandle);
-
-
- var lastError = Marshal.GetLastWin32Error();
- if (!success)
- {
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_DIR_NOT_EMPTY:
- // MSDN: .NET 3.5+: IOException: The directory specified by path is not an empty directory.
- throw new DirectoryNotEmptyException(pathLp);
-
-
- case Win32Errors.ERROR_DIRECTORY:
- // MSDN: .NET 3.5+: DirectoryNotFoundException: Path refers to a file instead of a directory.
- if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath))
- throw new DirectoryNotFoundException(string.Format(CultureInfo.CurrentCulture, "({0}) {1}", Win32Errors.ERROR_INVALID_PARAMETER, string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, pathLp)));
- break;
-
-
- case Win32Errors.ERROR_PATH_NOT_FOUND:
- if (continueOnNotFound)
- return;
- break;
-
-
- case Win32Errors.ERROR_SHARING_VIOLATION:
- // MSDN: .NET 3.5+: IOException: The directory is being used by another process or there is an open handle on the directory.
- NativeError.ThrowException(lastError, pathLp);
- break;
-
-
- case Win32Errors.ERROR_ACCESS_DENIED:
- var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA();
- var dataInitialised = File.FillAttributeInfoCore(transaction, pathLp, ref data, false, true);
-
- if (data.dwFileAttributes != (FileAttributes) (-1))
- {
- if ((data.dwFileAttributes & FileAttributes.ReadOnly) != 0)
- {
- // MSDN: .NET 3.5+: IOException: The directory specified by path is read-only.
-
- if (ignoreReadOnly)
- {
- // Reset directory attributes.
- File.SetAttributesCore(true, transaction, pathLp, FileAttributes.Normal, PathFormat.LongFullPath);
- goto startRemoveDirectory;
- }
-
- // MSDN: .NET 3.5+: IOException: The directory is read-only.
- throw new DirectoryReadOnlyException(pathLp);
- }
- }
-
-
- // MSDN: .NET 3.5+: UnauthorizedAccessException: The caller does not have the required permission.
- if (dataInitialised == Win32Errors.ERROR_SUCCESS)
- NativeError.ThrowException(lastError, pathLp);
-
- break;
- }
-
- // MSDN: .NET 3.5+: IOException:
- // A file with the same name and location specified by path exists.
- // The directory specified by path is read-only, or recursive is false and path is not an empty directory.
- // The directory is the application's current working directory.
- // The directory contains a read-only file.
- // The directory is being used by another process.
-
- NativeError.ThrowException(lastError, pathLp);
- }
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs
deleted file mode 100644
index 299c6ec..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs
+++ /dev/null
@@ -1,333 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove empty subdirectories from.
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, false, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path, bool recursive)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, recursive, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path, bool recursive, PathFormat pathFormat)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, recursive, false, pathFormat);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path, bool recursive, bool ignoreReadOnly)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, recursive, ignoreReadOnly, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, recursive, ignoreReadOnly, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from.
- [SecurityCritical]
- public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path)
- {
- DeleteEmptySubdirectoriesCore(null, transaction, path, false, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- [SecurityCritical]
- public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive)
- {
- DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, PathFormat pathFormat)
- {
- DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, false, pathFormat);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- [SecurityCritical]
- public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly)
- {
- DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, ignoreReadOnly, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Deletes empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat)
- {
- DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, ignoreReadOnly, pathFormat);
- }
-
- #endregion // Transactional
-
-
- #region Internal Methods
-
- /// [AlphaFS] Delete empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// A FileSystemEntryInfo instance. Use either or , not both.
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from. Use either or , not both.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- /// When indicates the method is called externally.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void DeleteEmptySubdirectoriesCore0(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool initialize, PathFormat pathFormat)
- {
- #region Setup
-
- if (fsEntryInfo == null)
- {
- if (pathFormat == PathFormat.RelativePath)
- Path.CheckSupportedPathFormat(path, true, true);
-
- if (!File.ExistsCore(true, transaction, path, pathFormat))
- NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, path);
-
- fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck) , false, pathFormat);
-
- if (fsEntryInfo == null)
- return;
- }
-
- #endregion // Setup
-
-
- // Ensure path is a directory.
- if (!fsEntryInfo.IsDirectory)
- throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, fsEntryInfo.LongFullPath));
-
-
- var dirEnumOptions = DirectoryEnumerationOptions.Folders | DirectoryEnumerationOptions.SkipReparsePoints;
-
- if (recursive)
- dirEnumOptions |= DirectoryEnumerationOptions.Recursive;
-
-
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, dirEnumOptions, PathFormat.LongFullPath))
- DeleteEmptySubdirectoriesCore0(fsei, transaction, null, recursive, ignoreReadOnly, false, PathFormat.LongFullPath);
-
-
- if (!EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).Any())
- {
- // Prevent deleting path itself.
- if (!initialize)
- DeleteDirectoryCore(fsEntryInfo, transaction, null, false, ignoreReadOnly, true, PathFormat.LongFullPath);
- }
- }
-
-
- /// [AlphaFS] Delete empty subdirectories from the specified directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// A FileSystemEntryInfo instance. Use either or , not both.
- /// The transaction.
- /// The name of the directory to remove empty subdirectories from. Use either or , not both.
- /// deletes empty subdirectories from this directory and its subdirectories.
- /// overrides read only of empty directories.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void DeleteEmptySubdirectoriesCore(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat)
- {
- #region Setup
-
- if (fsEntryInfo == null)
- {
- if (pathFormat == PathFormat.RelativePath)
- Path.CheckSupportedPathFormat(path, true, true);
-
- if (!File.ExistsCore(true, transaction, path, pathFormat))
- NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, path);
-
- fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck), false, pathFormat);
-
- if (fsEntryInfo == null)
- return;
- }
-
- #endregion // Setup
-
-
- // Ensure path is a directory.
- if (!fsEntryInfo.IsDirectory)
- throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, fsEntryInfo.LongFullPath));
-
-
- var dirs = new Stack(1000);
- dirs.Push(fsEntryInfo.LongFullPath);
-
- while (dirs.Count > 0)
- {
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, dirs.Pop(), Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders | DirectoryEnumerationOptions.ContinueOnException, PathFormat.LongFullPath))
- {
- // Ensure the directory is empty.
- if (!EnumerateFileSystemEntryInfosCore(transaction, fsei.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).Any())
- DeleteDirectoryCore(fsei, transaction, null, false, ignoreReadOnly, true, PathFormat.LongFullPath);
-
- else if (recursive)
- dirs.Push(fsei.LongFullPath);
- }
- }
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs
deleted file mode 100644
index ee0698e..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System.IO;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region Export
-
- /// [AlphaFS] Backs up (export) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// The directory being backed up is not decrypted; it is backed up in its encrypted state.
- /// If the caller does not have access to the key for the file, the caller needs to export encrypted files. See .
- /// To backup an encrypted directory call one of the overloads and specify the directory to backup along with the destination stream of the backup data.
- /// This function is intended for the backup of only encrypted directories; see for backup of unencrypted directories.
- /// Note that this method does not back up the files inside the directory, only the directory entry itself.
- ///
- ///
- ///
- ///
- /// The name of the file to be backed up.
- /// The destination stream to which the backup data will be written.
- public static void ExportEncryptedDirectoryRaw(string fileName, Stream outputStream)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, PathFormat.RelativePath, false);
- }
-
- /// [AlphaFS] Backs up (export) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// The directory being backed up is not decrypted; it is backed up in its encrypted state.
- /// If the caller does not have access to the key for the file, the caller needs to export encrypted files. See .
- /// To backup an encrypted directory call one of the overloads and specify the directory to backup along with the destination stream of the backup data.
- /// This function is intended for the backup of only encrypted directories; see for backup of unencrypted directories.
- /// Note that this method does not back up the files inside the directory, only the directory entry itself.
- ///
- ///
- ///
- ///
- /// The name of the file to be backed up.
- /// The destination stream to which the backup data will be written.
- /// The path format of the parameter.
- public static void ExportEncryptedDirectoryRaw(string fileName, Stream outputStream, PathFormat pathFormat)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, pathFormat, false);
- }
-
- #endregion // Export
-
- #region Import
-
- /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See .
- /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data.
- /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files.
- ///
- ///
- ///
- ///
- /// The stream to read previously backed up data from.
- /// The path of the destination directory to restore to.
- public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, PathFormat.RelativePath, false);
- }
-
- /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See .
- /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data.
- /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files.
- ///
- ///
- ///
- ///
- /// The stream to read previously backed up data from.
- /// The path of the destination directory to restore to.
- /// The path format of the parameter.
- public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, PathFormat pathFormat)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, pathFormat, false);
- }
-
-
- /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See .
- /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data.
- /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files.
- ///
- ///
- ///
- ///
- /// The stream to read previously backed up data from.
- /// The path of the destination directory to restore to.
- /// If set to a hidden directory will be overwritten on import.
- public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, bool overwriteHidden)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, PathFormat.RelativePath, overwriteHidden);
- }
-
- /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is
- /// intended to implement backup and restore functionality, while maintaining files in their encrypted state.
- ///
- ///
- /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See .
- /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data.
- /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files.
- ///
- ///
- ///
- ///
- /// The stream to read previously backed up data from.
- /// The path of the destination directory to restore to.
- /// If set to a hidden directory will be overwritten on import.
- /// The path format of the parameter.
- public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, bool overwriteHidden, PathFormat pathFormat)
- {
- File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, pathFormat, overwriteHidden);
- }
-
- #endregion // Import
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs
deleted file mode 100644
index 5b1c780..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs
+++ /dev/null
@@ -1,272 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region Decrypt
-
- /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decrypt.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Decrypt(string path, PathFormat pathFormat)
- {
- EncryptDecryptDirectoryCore(path, false, false, pathFormat);
- }
-
- /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decrypt.
- /// to decrypt the directory recursively. only decrypt the directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Decrypt(string path, bool recursive, PathFormat pathFormat)
- {
- EncryptDecryptDirectoryCore(path, false, recursive, pathFormat);
- }
-
- /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decrypt.
- [SecurityCritical]
- public static void Decrypt(string path)
- {
- EncryptDecryptDirectoryCore(path, false, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to decrypt.
- /// to decrypt the directory recursively. only decrypt the directory.
- [SecurityCritical]
- public static void Decrypt(string path, bool recursive)
- {
- EncryptDecryptDirectoryCore(path, false, recursive, PathFormat.RelativePath);
- }
-
- #endregion // Decrypt
-
- #region Encrypt
-
- /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to encrypt.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Encrypt(string path, PathFormat pathFormat)
- {
- EncryptDecryptDirectoryCore(path, true, false, pathFormat);
- }
-
- /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to encrypt.
- /// to encrypt the directory recursively. only encrypt the directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void Encrypt(string path, bool recursive, PathFormat pathFormat)
- {
- EncryptDecryptDirectoryCore(path, true, recursive, pathFormat);
- }
-
-
- /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to encrypt.
- [SecurityCritical]
- public static void Encrypt(string path)
- {
- EncryptDecryptDirectoryCore(path, true, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to encrypt.
- /// to encrypt the directory recursively. only encrypt the directory.
- [SecurityCritical]
- public static void Encrypt(string path, bool recursive)
- {
- EncryptDecryptDirectoryCore(path, true, recursive, PathFormat.RelativePath);
- }
-
- #endregion // Encrypt
-
- #region DisableEncryption
-
- /// [AlphaFS] Disables encryption of the specified directory and the files in it.
- /// This method only creates/modifies the file "Desktop.ini" in the root of and disables encryption by writing: "Disable=1"
- /// This method does not affect encryption of files and subdirectories below the indicated directory.
- ///
- /// The name of the directory for which to disable encryption.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void DisableEncryption(string path, PathFormat pathFormat)
- {
- EnableDisableEncryptionCore(path, false, pathFormat);
- }
-
- /// [AlphaFS] Disables encryption of the specified directory and the files in it.
- /// This method only creates/modifies the file "Desktop.ini" in the root of and disables encryption by writing: "Disable=1"
- /// This method does not affect encryption of files and subdirectories below the indicated directory.
- ///
- /// The name of the directory for which to disable encryption.
- [SecurityCritical]
- public static void DisableEncryption(string path)
- {
- EnableDisableEncryptionCore(path, false, PathFormat.RelativePath);
- }
-
- #endregion // DisableEncryption
-
- #region EnableEncryption
-
- /// [AlphaFS] Enables encryption of the specified directory and the files in it.
- /// This method only creates/modifies the file "Desktop.ini" in the root of and enables encryption by writing: "Disable=0"
- /// This method does not affect encryption of files and subdirectories below the indicated directory.
- ///
- /// The name of the directory for which to enable encryption.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static void EnableEncryption(string path, PathFormat pathFormat)
- {
- EnableDisableEncryptionCore(path, true, pathFormat);
- }
-
- /// [AlphaFS] Enables encryption of the specified directory and the files in it.
- /// This method only creates/modifies the file "Desktop.ini" in the root of and enables encryption by writing: "Disable=0"
- /// This method does not affect encryption of files and subdirectories below the indicated directory.
- ///
- /// The name of the directory for which to enable encryption.
- [SecurityCritical]
- public static void EnableEncryption(string path)
- {
- EnableDisableEncryptionCore(path, true, PathFormat.RelativePath);
- }
-
- #endregion // EnableEncryption
-
- #region Internal Methods
-
- /// Enables/disables encryption of the specified directory and the files in it.
- /// This method only creates/modifies the file "Desktop.ini" in the root of and enables/disables encryption by writing: "Disable=0" or "Disable=1".
- /// This method does not affect encryption of files and subdirectories below the indicated directory.
- ///
- /// The name of the directory for which to enable encryption.
- /// enabled encryption, disables encryption.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void EnableDisableEncryptionCore(string path, bool enable, PathFormat pathFormat)
- {
- if (Utils.IsNullOrWhiteSpace(path))
- throw new ArgumentNullException("path");
-
- string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
-
- // EncryptionDisable()
- // In the ANSI version of this function, the name is limited to 248 characters.
- // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
- // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
-
- if (!NativeMethods.EncryptionDisable(pathLp, !enable))
- NativeError.ThrowException(pathLp);
- }
-
- /// Decrypts/encrypts a directory recursively so that only the account used to encrypt the directory can decrypt it.
- ///
- ///
- ///
- ///
- ///
- ///
- /// A path that describes a directory to encrypt.
- /// encrypt, decrypt.
- /// to decrypt the directory recursively. only decrypt files and directories in the root of .
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void EncryptDecryptDirectoryCore(string path, bool encrypt, bool recursive, PathFormat pathFormat)
- {
- string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
-
- var options = DirectoryEnumerationOptions.FilesAndFolders | DirectoryEnumerationOptions.AsLongPath;
-
- // Process folders and files when recursive.
- if (recursive)
- {
- options |= DirectoryEnumerationOptions.Recursive;
-
- foreach (string fsei in EnumerateFileSystemEntryInfosCore(null, pathLp, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath))
- File.EncryptDecryptFileCore(true, fsei, encrypt, PathFormat.LongFullPath);
- }
-
- // Process the root folder, the given path.
- File.EncryptDecryptFileCore(true, pathLp, encrypt, PathFormat.LongFullPath);
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs
deleted file mode 100644
index 8ddcf9d..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System.Collections.Generic;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory.
- /// The path to the directory to enumerate streams of.
- /// The streams of type :$DATA in the specified directory.
- [SecurityCritical]
- public static IEnumerable EnumerateAlternateDataStreams(string path)
- {
- return File.EnumerateAlternateDataStreamsCore(null, path, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory.
- /// The path to the directory to enumerate streams of.
- /// Indicates the format of the path parameter(s).
- /// The streams of type :$DATA in the specified directory.
- [SecurityCritical]
- public static IEnumerable EnumerateAlternateDataStreams(string path, PathFormat pathFormat)
- {
- return File.EnumerateAlternateDataStreamsCore(null, path, pathFormat);
- }
-
- /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory.
- /// The transaction.
- /// The path to the directory to enumerate streams of.
- /// The streams of type :$DATA in the specified directory.
- [SecurityCritical]
- public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path)
- {
- return File.EnumerateAlternateDataStreamsCore(transaction, path, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory.
- /// The transaction.
- /// The path to the directory to enumerate streams of.
- /// Indicates the format of the path parameter(s).
- /// The streams of type :$DATA in the specified directory.
- [SecurityCritical]
- public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.EnumerateAlternateDataStreamsCore(transaction, path, pathFormat);
- }
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
deleted file mode 100644
index d666b10..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
+++ /dev/null
@@ -1,500 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath);
- }
-
- /// Returns an enumerable collection of directory names that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath);
- }
-
- /// Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files; // Remove enumeration of files.
- options |= DirectoryEnumerationOptions.Folders; // Add enumeration of directories.
-
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectories(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- #region Transactional
-
- /// [AlphaFS] Returns an enumerable collection of directory instances in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory instances in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory instances in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory instances in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Files;
- options |= DirectoryEnumerationOptions.Folders;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
deleted file mode 100644
index 68f63aa..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Microsoft.Win32.SafeHandles;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// A path to a directory from which to retrieve information.
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path)
- {
- return EnumerateFileIdBothDirectoryInfoCore(null, null, path, FileShare.ReadWrite, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// A path to a directory from which to retrieve information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, PathFormat pathFormat)
- {
- return EnumerateFileIdBothDirectoryInfoCore(null, null, path, FileShare.ReadWrite, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// A path to a directory from which to retrieve information.
- /// The mode with which to open a handle to the directory.
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, FileShare shareMode)
- {
- return EnumerateFileIdBothDirectoryInfoCore(null, null, path, shareMode, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// A path to a directory from which to retrieve information.
- /// The mode with which to open a handle to the directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, FileShare shareMode, PathFormat pathFormat)
- {
- return EnumerateFileIdBothDirectoryInfoCore(null, null, path, shareMode, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Retrieves information about files in the directory handle specified.
- /// An IEnumerable of records for each file system entry in the specified diretory.
- /// An open handle to the directory from which to retrieve information.
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfo(SafeFileHandle handle)
- {
- // FileShare has no effect since a handle is already opened.
- return EnumerateFileIdBothDirectoryInfoCore(null, handle, null, FileShare.ReadWrite, false, PathFormat.RelativePath);
- }
-
- #region Transactional
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// The transaction.
- /// A path to a directory from which to retrieve information.
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, FileShare.ReadWrite, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// The transaction.
- /// A path to a directory from which to retrieve information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, FileShare.ReadWrite, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// The transaction.
- /// A path to a directory from which to retrieve information.
- /// The mode with which to open a handle to the directory.
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, FileShare shareMode)
- {
- return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, shareMode, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
- /// The transaction.
- /// A path to a directory from which to retrieve information.
- /// The mode with which to open a handle to the directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, FileShare shareMode, PathFormat pathFormat)
- {
- return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, shareMode, false, pathFormat);
- }
-
- #endregion // Transactional
-
- #region Internal Methods
-
- /// Returns an enumerable collection of information about files in the directory handle specified.
- /// An IEnumerable of records for each file system entry in the specified diretory.
- ///
- /// Either use or , not both.
- ///
- /// The number of files that are returned for each call to GetFileInformationByHandleEx depends on the size of the buffer that is passed to the function.
- /// Any subsequent calls to GetFileInformationByHandleEx on the same handle will resume the enumeration operation after the last file is returned.
- ///
- ///
- /// The transaction.
- /// An open handle to the directory from which to retrieve information.
- /// A path to the directory.
- /// The mode with which to open a handle to the directory.
- /// suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or non-accessible reparse points.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static IEnumerable EnumerateFileIdBothDirectoryInfoCore(KernelTransaction transaction, SafeFileHandle safeHandle, string path, FileShare shareMode, bool continueOnException, PathFormat pathFormat)
- {
- if (!NativeMethods.IsAtLeastWindowsVista)
- throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher);
-
- bool callerHandle = safeHandle != null;
- if (!callerHandle)
- {
- if (Utils.IsNullOrWhiteSpace(path))
- throw new ArgumentNullException("path");
-
- string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
-
- safeHandle = File.CreateFileCore(transaction, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, shareMode, true, PathFormat.LongFullPath);
- }
-
-
- try
- {
- if (!NativeMethods.IsValidHandle(safeHandle, Marshal.GetLastWin32Error(), !continueOnException))
- yield break;
-
- var fileNameOffset = (int)Marshal.OffsetOf(typeof(NativeMethods.FILE_ID_BOTH_DIR_INFO), "FileName");
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize))
- {
- while (true)
- {
- if (!NativeMethods.GetFileInformationByHandleEx(safeHandle, NativeMethods.FileInfoByHandleClass.FileIdBothDirectoryInfo, safeBuffer, (uint)safeBuffer.Capacity))
- {
- uint lastError = (uint)Marshal.GetLastWin32Error();
- switch (lastError)
- {
- case Win32Errors.ERROR_SUCCESS:
- case Win32Errors.ERROR_NO_MORE_FILES:
- case Win32Errors.ERROR_HANDLE_EOF:
- yield break;
-
- case Win32Errors.ERROR_MORE_DATA:
- continue;
-
- default:
- NativeError.ThrowException(lastError, path);
- yield break; // we should never get to this yield break.
- }
- }
-
- int offset = 0;
- NativeMethods.FILE_ID_BOTH_DIR_INFO fibdi;
- do
- {
- fibdi = safeBuffer.PtrToStructure(offset);
- string fileName = safeBuffer.PtrToStringUni(offset + fileNameOffset, (int)(fibdi.FileNameLength / 2));
-
- if (!fileName.Equals(Path.CurrentDirectoryPrefix, StringComparison.OrdinalIgnoreCase) &&
- !fileName.Equals(Path.ParentDirectoryPrefix, StringComparison.OrdinalIgnoreCase))
- yield return new FileIdBothDirectoryInfo(fibdi, fileName);
-
- offset += fibdi.NextEntryOffset;
- }
- while (fibdi.NextEntryOffset != 0);
- }
- }
- }
- finally
- {
- // Handle is ours, dispose.
- if (!callerHandle && safeHandle != null)
- safeHandle.Close();
- }
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
deleted file mode 100644
index f346b00..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
+++ /dev/null
@@ -1,472 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
-
-
- /// Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- #region Transactional
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
deleted file mode 100644
index 890d394..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
+++ /dev/null
@@ -1,670 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
- #region Transactional
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")]
- [SecurityCritical]
- public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
- #endregion // Transactional
-
- #region Internal Methods
-
- /// Returns an enumerable collection of file system entries in a specified path using .
- /// The matching file system entries. The type of the items is determined by the type .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The type to return. This may be one of the following types:
- ///
- ///
- ///
- /// This method will return instances of instances.
- ///
- ///
- ///
- /// This method will return instances of and instances.
- ///
- ///
- ///
- /// This method will return the full path of each item.
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static IEnumerable EnumerateFileSystemEntryInfosCore(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Enable BasicSearch and LargeCache by default.
- options |= DirectoryEnumerationOptions.BasicSearch | DirectoryEnumerationOptions.LargeCache;
-
- return new FindFileSystemEntryInfo(true, transaction, path, searchPattern, options, typeof(T), pathFormat).Enumerate();
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
deleted file mode 100644
index f4ee086..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
+++ /dev/null
@@ -1,502 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath);
- }
-
- /// Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath);
- }
-
- /// Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders; // Remove enumeration of directories.
- options |= DirectoryEnumerationOptions.Files; // Add enumeration of files.
-
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFiles(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat);
- }
-
-
-
- #region Transactional
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file instances instances that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Files, pathFormat);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file instances instances that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat)
- {
- var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat);
- }
-
-
-
- /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- /// flags that specify how the directory is to be enumerated.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat)
- {
- // Adhere to the method name.
- options &= ~DirectoryEnumerationOptions.Folders;
- options |= DirectoryEnumerationOptions.Files;
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs
deleted file mode 100644
index c0639b0..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Determines whether the given path refers to an existing directory on disk.
- ///
- /// Returns if refers to an existing directory.
- /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists.
- ///
- ///
- /// The Exists method returns if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
- ///
- /// The path to test.
- [SecurityCritical]
- public static bool Exists(string path)
- {
- return File.ExistsCore(true, null, path, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
-
-
- /// [AlphaFS] Determines whether the given path refers to an existing directory on disk.
- ///
- /// Returns if refers to an existing directory.
- /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists.
- ///
- ///
- /// The Exists method returns if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
- ///
- /// The path to test.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static bool Exists(string path, PathFormat pathFormat)
- {
- return File.ExistsCore(true, null, path, pathFormat);
- }
-
- #region Transactional
-
- /// [AlphaFS] Determines whether the given path refers to an existing directory on disk.
- ///
- /// Returns if refers to an existing directory.
- /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists.
- ///
- ///
- /// The Exists method returns if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
- ///
- /// The transaction.
- /// The path to test.
- [SecurityCritical]
- public static bool ExistsTransacted(KernelTransaction transaction, string path)
- {
- return File.ExistsCore(true, transaction, path, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Determines whether the given path refers to an existing directory on disk.
- ///
- /// Returns if refers to an existing directory.
- /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists.
- ///
- ///
- /// The Exists method returns if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
- ///
- /// The transaction.
- /// The path to test.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static bool ExistsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.ExistsCore(true, transaction, path, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
deleted file mode 100644
index 9d90e02..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-using Alphaleonis.Win32.Security;
-using Microsoft.Win32.SafeHandles;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// Gets a object that encapsulates the access control list (ACL) entries for the specified directory.
- /// A object that encapsulates the access control rules for the file described by the parameter.
- ///
- ///
- ///
- /// The path to a directory containing a object that describes the file's access control list (ACL) information.
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(string path)
- {
- return File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.RelativePath);
- }
-
- /// Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory.
- /// A object that encapsulates the access control rules for the directory described by the parameter.
- ///
- ///
- ///
- /// The path to a directory containing a object that describes the directory's access control list (ACL) information.
- /// One (or more) of the values that specifies the type of access control list (ACL) information to receive.
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections)
- {
- return File.GetAccessControlCore(true, path, includeSections, PathFormat.RelativePath);
- }
-
-
- /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory.
- /// A object that encapsulates the access control rules for the file described by the parameter.
- ///
- ///
- ///
- /// The path to a directory containing a object that describes the file's access control list (ACL) information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(string path, PathFormat pathFormat)
- {
- return File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, pathFormat);
- }
-
- /// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory.
- /// A object that encapsulates the access control rules for the directory described by the parameter.
- ///
- ///
- ///
- /// The path to a directory containing a object that describes the directory's access control list (ACL) information.
- /// One (or more) of the values that specifies the type of access control list (ACL) information to receive.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections, PathFormat pathFormat)
- {
- return File.GetAccessControlCore(true, path, includeSections, pathFormat);
- }
-
-
- /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory handle.
- /// A object that encapsulates the access control rules for the file described by the parameter.
- ///
- ///
- ///
- /// A to a directory containing a object that describes the directory's access control list (ACL) information.
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(SafeFileHandle handle)
- {
- return File.GetAccessControlHandleCore(false, true, handle, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, SecurityInformation.None);
- }
-
- /// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory handle.
- /// A object that encapsulates the access control rules for the directory described by the parameter.
- ///
- ///
- ///
- /// A to a directory containing a object that describes the directory's access control list (ACL) information.
- /// One (or more) of the values that specifies the type of access control list (ACL) information to receive.
- [SecurityCritical]
- public static DirectorySecurity GetAccessControl(SafeFileHandle handle, AccessControlSections includeSections)
- {
- return File.GetAccessControlHandleCore(false, true, handle, includeSections, SecurityInformation.None);
- }
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs
deleted file mode 100644
index d70676c..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Microsoft.Win32.SafeHandles;
-using System;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- /// [AlphaFS] Gets the change date and time of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in local time.
- /// The directory for which to obtain creation date and time information.
- [SecurityCritical]
- public static DateTime GetChangeTime(string path)
- {
- return File.GetChangeTimeCore(true, null, null, path, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the change date and time of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in local time.
- /// The directory for which to obtain creation date and time information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetChangeTime(string path, PathFormat pathFormat)
- {
- return File.GetChangeTimeCore(true, null, null, path, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time.
- /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.
- [SecurityCritical]
- public static DateTime GetChangeTimeUtc(string path)
- {
- return File.GetChangeTimeCore(true, null, null, path, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time.
- /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat)
- {
- return File.GetChangeTimeCore(true, null, null, path, true, pathFormat);
- }
-
-
-
- /// [AlphaFS] Gets the change date and time of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in local time.
- /// An open handle to the directory from which to retrieve information.
- [SecurityCritical]
- public static DateTime GetChangeTime(SafeFileHandle safeHandle)
- {
- return File.GetChangeTimeCore(true, null, safeHandle, null, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time.
- /// An open handle to the directory from which to retrieve information.
- [SecurityCritical]
- public static DateTime GetChangeTimeUtc(SafeFileHandle safeHandle)
- {
- return File.GetChangeTimeCore(true, null, safeHandle, null, true, PathFormat.RelativePath);
- }
-
- #region Transactional
-
- /// [AlphaFS] Gets the change date and time of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in local time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information.
- [SecurityCritical]
- public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path)
- {
- return File.GetChangeTimeCore(true, transaction, null, path, false, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the change date and time of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in local time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.GetChangeTimeCore(true, transaction, null, path, false, pathFormat);
- }
-
-
-
- /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time.
- /// The transaction.
- /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.
- [SecurityCritical]
- public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path)
- {
- return File.GetChangeTimeCore(true, transaction, null, path, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time.
- /// The transaction.
- /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.GetChangeTimeCore(true, transaction, null, path, true, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs
deleted file mode 100644
index 8b6b3aa..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Gets the creation date and time of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in local time.
- /// The directory for which to obtain creation date and time information.
- [SecurityCritical]
- public static DateTime GetCreationTime(string path)
- {
- return File.GetCreationTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime();
- }
-
-
-
- /// Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time.
- /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.
- [SecurityCritical]
- public static DateTime GetCreationTimeUtc(string path)
- {
- return File.GetCreationTimeCore(null, path, true, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// [AlphaFS] Gets the creation date and time of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in local time.
- /// The directory for which to obtain creation date and time information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetCreationTime(string path, PathFormat pathFormat)
- {
- return File.GetCreationTimeCore(null, path, false, pathFormat).ToLocalTime();
- }
-
-
-
- /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time.
- /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetCreationTimeUtc(string path, PathFormat pathFormat)
- {
- return File.GetCreationTimeCore(null, path, true, pathFormat);
- }
-
-
- #region Transactional
-
- /// [AlphaFS] Gets the creation date and time of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in local time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information.
- [SecurityCritical]
- public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path)
- {
- return File.GetCreationTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime();
- }
-
- /// [AlphaFS] Gets the creation date and time of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in local time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.GetCreationTimeCore(transaction, path, false, pathFormat).ToLocalTime();
- }
-
-
-
- /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.
- [SecurityCritical]
- public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path)
- {
- return File.GetCreationTimeCore(transaction, path, true, PathFormat.RelativePath);
- }
-
- /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.
- /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time.
- /// The transaction.
- /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return File.GetCreationTimeCore(transaction, path, true, pathFormat);
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
deleted file mode 100644
index ccac010..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- // Since Directory.GetDirectories() is less efficient than Directory.EnumerateDirectories(),
- // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods.
-
- #region .NET
-
- /// Returns the names of subdirectories (including their paths) in the specified directory.
- /// An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- [SecurityCritical]
- public static string[] GetDirectories(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
- /// An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static string[] GetDirectories(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories.
- /// An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static string[] GetDirectories(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray();
- }
-
- #endregion // .NET
-
- #region Transactional
-
- /// Returns the names of subdirectories (including their paths) in the specified directory.
- /// An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- [SecurityCritical]
- public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
- /// An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories.
- /// An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
- ///
- /// The names returned by this method are prefixed with the directory information provided in path.
- /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).ToArray();
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs
deleted file mode 100644
index 91b62f6..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Security;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- #region .NET
-
- /// Returns the volume information, root information, or both for the specified path.
- /// The volume information, root information, or both for the specified path, or if path does not contain root directory information.
- ///
- ///
- ///
- /// The path of a file or directory.
- [SecurityCritical]
- public static string GetDirectoryRoot(string path)
- {
- return GetDirectoryRootCore(null, path, PathFormat.RelativePath);
- }
-
- #endregion // .NET
-
- /// Returns the volume information, root information, or both for the specified path.
- /// The volume information, root information, or both for the specified path, or if path does not contain root directory information.
- ///
- ///
- ///
- /// The path of a file or directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static string GetDirectoryRoot(string path, PathFormat pathFormat)
- {
- return GetDirectoryRootCore(null, path, pathFormat);
- }
-
- #region Transactional
-
- /// [AlphaFS] Returns the volume information, root information, or both for the specified path.
- /// The volume information, root information, or both for the specified path, or if path does not contain root directory information.
- ///
- ///
- ///
- /// The transaction.
- /// The path of a file or directory.
- [SecurityCritical]
- public static string GetDirectoryRootTransacted(KernelTransaction transaction, string path)
- {
- return GetDirectoryRootCore(transaction, path, PathFormat.RelativePath);
- }
-
- /// Returns the volume information, root information, or both for the specified path.
- /// The volume information, root information, or both for the specified path, or if path does not contain root directory information.
- ///
- ///
- ///
- /// The transaction.
- /// The path of a file or directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- public static string GetDirectoryRootTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- return GetDirectoryRootCore(transaction, path, pathFormat);
- }
-
- #endregion // Transactional
-
- #region Internal Methods
-
- /// Returns the volume information, root information, or both for the specified path.
- /// The volume information, root information, or both for the specified path, or if path does not contain root directory information.
- ///
- ///
- ///
- /// The transaction.
- /// The path of a file or directory.
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static string GetDirectoryRootCore(KernelTransaction transaction, string path, PathFormat pathFormat)
- {
- Path.CheckInvalidUncPath(path);
-
- string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.CheckInvalidPathChars);
-
- pathLp = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false);
-
- string rootPath = Path.GetPathRoot(pathLp, false);
-
- return Utils.IsNullOrWhiteSpace(rootPath) ? null : rootPath;
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
deleted file mode 100644
index e4974a0..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- // Since Directory.GetFileSystemEntries() is less efficient than Directory.EnumerateFileSystemEntries(),
- // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods.
-
- #region .NET
-
- /// Returns the names of all files and subdirectories in the specified directory.
- /// An string[] array of the names of files and subdirectories in the specified directory.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory for which file and subdirectory names are returned.
- [SecurityCritical]
- public static string[] GetFileSystemEntries(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns an array of file system entries that match the specified search criteria.
- /// An string[] array of file system entries that match the specified search criteria.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The path to be searched.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static string[] GetFileSystemEntries(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray();
- }
-
- /// Gets an array of all the file names and directory names that match a in a specified path, and optionally searches subdirectories.
- /// An string[] array of file system entries that match the specified search criteria.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray();
- }
-
- #endregion // .NET
-
- #region Transactional
-
- /// Returns the names of all files and subdirectories in the specified directory.
- /// An string[] array of the names of files and subdirectories in the specified directory.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory for which file and subdirectory names are returned.
- [SecurityCritical]
- public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns an array of file system entries that match the specified search criteria.
- /// An string[] array of file system entries that match the specified search criteria.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The path to be searched.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray();
- }
-
- /// Gets an array of all the file names and directory names that match a in a specified path, and optionally searches subdirectories.
- /// An string[] array of file system entries that match the specified search criteria.
- ///
- /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
- /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
- /// you must wait for the whole array of entries to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The transaction.
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).ToArray();
- }
-
- #endregion // Transactional
- }
-}
diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
deleted file mode 100644
index 4d1d46f..0000000
--- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Security;
-using SearchOption = System.IO.SearchOption;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- partial class Directory
- {
- // Since Directory.GetFiles() is less efficient than Directory.EnumerateFiles(),
- // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods.
-
- #region .NET
-
- /// Returns the names of files (including their paths) in the specified directory.
- /// An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
- ///
- /// The returned file names are appended to the supplied parameter.
- /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
- /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- [SecurityCritical]
- public static string[] GetFiles(string path)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
- /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
- ///
- /// The returned file names are appended to the supplied parameter.
- /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
- /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- [SecurityCritical]
- public static string[] GetFiles(string path, string searchPattern)
- {
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray();
- }
-
- /// Returns the names of files (including their paths) that match the specified search pattern in the current directory, and optionally searches subdirectories.
- /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found.
- ///
- /// The returned file names are appended to the supplied parameter.
- /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
- /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names
- /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array.
- /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The directory to search.
- ///
- /// The search string to match against the names of directories in .
- /// This parameter can contain a combination of valid literal path and wildcard
- /// ( and ) characters, but does not support regular expressions.
- ///
- ///
- /// One of the enumeration values that specifies whether the
- /// should include only the current directory or should include all subdirectories.
- ///
- [SecurityCritical]
- public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
- {
- var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0);
-
- return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray();
- }
-
- #endregion // .NET
-
- #region Transactional
-
- /// Returns the names of files (including their paths) in the specified directory.
- /// An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
- ///
- /// The returned file names are appended to the supplied