Ejemplo n.º 1
0
        public List <string> ListShares()
        {
            if (!IsConnected || !m_isLoggedIn)
            {
                throw new InvalidOperationException("A login session must be successfully established before retrieving share list");
            }

            SMB1FileStore namedPipeShare = TreeConnect("IPC$", ServiceName.NamedPipe);

            List <string> shares = ServerServiceHelper.ListShares(namedPipeShare, ShareType.DiskDrive);

            namedPipeShare.Disconnect();
            return(shares);
        }
Ejemplo n.º 2
0
        public List <string> ListShares(out NTStatus status)
        {
            if (!m_isConnected || !m_isLoggedIn)
            {
                throw new InvalidOperationException("A login session must be successfully established before retrieving share list");
            }

            ISMBFileStore namedPipeShare = TreeConnect("IPC$", out status);

            if (namedPipeShare == null)
            {
                return(null);
            }

            List <string> shares = ServerServiceHelper.ListShares(namedPipeShare, SMBLibrary.Services.ShareType.DiskDrive, out status);

            namedPipeShare.Disconnect();
            return(shares);
        }
Ejemplo n.º 3
0
        public async Task <(NTStatus status, IEnumerable <string> shares)> ListShares(CancellationToken cancellationToken)
        {
            if (!m_isConnected || !m_isLoggedIn)
            {
                throw new InvalidOperationException("A login session must be successfully established before retrieving share list");
            }

            var(status, namedPipeShare) = await TreeConnectAsync("IPC$", cancellationToken);

            if (namedPipeShare == null)
            {
                return(status, Enumerable.Empty <string>());
            }

            IEnumerable <string> shares = null;

            (status, shares) = await ServerServiceHelper.ListShares(namedPipeShare, Services.ShareType.DiskDrive, cancellationToken);

            await namedPipeShare.DisconnectAsync();

            return(status, shares);
        }