diff --git a/SMBLibrary/Client/SMB1FileStore.cs b/SMBLibrary/Client/SMB1FileStore.cs index dfd100b..4d248c9 100644 --- a/SMBLibrary/Client/SMB1FileStore.cs +++ b/SMBLibrary/Client/SMB1FileStore.cs @@ -384,6 +384,18 @@ namespace SMBLibrary.Client return NTStatus.STATUS_INVALID_SMB; } + public NTStatus Disconnect() + { + TreeDisconnectRequest request = new TreeDisconnectRequest(); + TrySendMessage(request); + SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TREE_DISCONNECT); + if (reply != null) + { + return reply.Header.Status; + } + return NTStatus.STATUS_INVALID_SMB; + } + private static ExtendedFileAttributes ToExtendedFileAttributes(FileAttributes fileAttributes) { // We only return flags that can be used with NtCreateFile diff --git a/SMBLibrary/Client/SMB2FileStore.cs b/SMBLibrary/Client/SMB2FileStore.cs index 5071a49..f5c2983 100644 --- a/SMBLibrary/Client/SMB2FileStore.cs +++ b/SMBLibrary/Client/SMB2FileStore.cs @@ -177,6 +177,19 @@ namespace SMBLibrary.Client return NTStatus.STATUS_INVALID_SMB; } + public NTStatus Disconnect() + { + TreeDisconnectRequest request = new TreeDisconnectRequest(); + TrySendCommand(request); + SMB2Command response = m_client.WaitForCommand(SMB2CommandName.TreeDisconnect); + if (response != null) + { + return response.Header.Status; + } + + return NTStatus.STATUS_INVALID_SMB; + } + private void TrySendCommand(SMB2Command request) { request.Header.TreeID = m_treeID;