protected override void DoDispose()
 {
     base.DoDispose();
     if (AccessType == TDirectoryAccessType.Direct && !IsXDCAM && string.IsNullOrWhiteSpace(Username))
     {
         PinvokeWindowsNetworking.DisconnectRemote(Path.GetPathRoot(Folder));
     }
     _ftpClient?.Dispose();
 }
        private bool _connectToRemoteDirectory()
        {
            string dir = Path.GetPathRoot(Folder);
            string ret = PinvokeWindowsNetworking.DisconnectRemote(dir);

            if (ret != null)
            {
                Debug.WriteLine(ret, $"DisconnectRemote {dir}");
            }
            ret = PinvokeWindowsNetworking.ConnectToRemote(dir, Username, Password);
            if (ret == null)
            {
                return(true);
            }
            Logger.Warn("Cannot connect to remote {0}. Error was: {1}", dir, ret);
            Debug.WriteLine(ret, $"ConnectToRemote {dir}");
            return(false);
        }