private static void CreateParentDirectoryIfNotExists(string path)
        {
            string dir = LongPath.GetDirectoryName(path);

            if (!string.IsNullOrEmpty(dir) && !LongPathDirectory.Exists(dir))
            {
                LongPathDirectory.CreateDirectory(dir);
            }
        }
        /// <summary>
        /// Validates the transfer location.
        /// </summary>
        public override void Validate()
        {
#if DOTNET5_4
            DirectoryInfo di = new DirectoryInfo(this.DirectoryPath);
            di.Create();
#else
            if (!LongPathDirectory.Exists(this.DirectoryPath))
            {
                LongPathDirectory.CreateDirectory(this.DirectoryPath);
            }
#endif
        }
        /// <summary>
        /// Creates all directories and subdirectories in the specified path unless they already exist.
        /// </summary>
        /// <param name="path">The directory to create.</param>
        public static void CreateDirectory(string path)
        {
#if DOTNET5_4
            Directory.CreateDirectory(path);
#else
            var dir = LongPath.GetDirectoryName(path);
            if (!string.IsNullOrEmpty(dir) && !LongPathDirectory.Exists(dir))
            {
                LongPathDirectory.CreateDirectory(dir);
            }

            path = LongPath.ToUncPath(path);

            if (!NativeMethods.CreateDirectoryW(path, IntPtr.Zero))
            {
                NativeMethods.ThrowExceptionForLastWin32ErrorIfExists(new int[] {
                    NativeMethods.ERROR_SUCCESS,
                    NativeMethods.ERROR_ALREADY_EXISTS
                });
            }
#endif
        }