public void Start() { IPAddress serverAddress = IPAddress.Parse(IpAddress); SMBTransportType transportType = SMBTransportType.DirectTCPTransport; UserCollection users = new UserCollection(); users.Add(UserName, UserPassword); NTLMAuthenticationProviderBase authenticationMechanism = new IndependentNTLMAuthenticationProvider(users.GetUserPassword); SMBShareCollection shares = new SMBShareCollection(); FileSystemShare share = new FileSystemShare("documents", new NTDirectoryFileSystem("/storage/emulated/0/Documents")); share.AccessRequested += delegate(object sender, AccessRequestArgs args) { // allow read and write on share args.Allow = true; }; shares.Add(share); GSSProvider securityProvider = new GSSProvider(authenticationMechanism); server = new SmbServer2(shares, securityProvider); try { server.Start(serverAddress, transportType, true, true); } catch (Exception ex) { } }
private void tsbServerState_CheckedChanged(object sender, EventArgs e) { tstbPort_Leave(sender, e); if (tsbServerState.Checked) { try { m_server.Start(serverAddress, transportType, true, false); } catch (Exception ex) { tsbServerState.Checked = false; tsbServerState.Image = Properties.Resources.start; tsbServerState.Text = "Server is stopped (press to start)"; tstbPort.Enabled = true; MessageBox.Show(ex.Message, "Error"); return; } m_logWriter.CloseLogFile(); tsbServerState.Image = Properties.Resources.stop; tsbServerState.Text = "Server is running (press to stop)"; tstbPort.Enabled = false; } else { m_server.Stop(); m_logWriter.CloseLogFile(); tsbServerState.Image = Properties.Resources.start; tsbServerState.Text = "Server is stopped (press to start)"; tstbPort.Enabled = true; } saveSettings(); }