public FrmSettings() { InitializeComponent(); AppConfigs conf = AppConfigs.Load(); if (conf != null) { ValidUsers_bindingList = new BindingList <Employee>(conf.Employees); var sourceUsers = new BindingSource(ValidUsers_bindingList, null); grdValidUsers.DataSource = sourceUsers; ValidExtensions_bindingList = new BindingList <FileExtensions>(conf.ValidExtensions); var sourceExtensions = new BindingSource(ValidExtensions_bindingList, null); grdValidExtensions.DataSource = sourceExtensions; } ServiceState st = ServiceHelper.GetServiceStatus("EFTService"); lblServicestatus.Text = Enum.GetName(typeof(ServiceState), st); btnUninstall.Visible = new[] { 1, 4, 7 }.Contains((int)st); lblCurrentUsername.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToLower(); CheckUserAccess(); }
private void FrmSettings_Load(object sender, EventArgs e) { AppConfigs conf = AppConfigs.Load(); txtServerIP.Text = conf.ServerIP; txtSavePath.Text = conf.SavePath; txtDomainUsername.Text = conf.DomainUsername; }
private void StartWatching() { watcher = new FileSystemWatcher(); watcher.Path = string.Concat(AppConfigs.Load().SavePath, "\\"); watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.CreationTime | NotifyFilters.FileName; watcher.Filter = "clipboard_ServerToClient.txt"; watcher.Created += Watcher_Created; watcher.Changed += Watcher_Created; watcher.EnableRaisingEvents = true; }
public void Send(string FilePath) { string _fName = string.Concat(Path.GetFileName(FilePath), "■", AppConfigs.Load().DomainUsername); // append username to filename Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); byte[] fileName = Encoding.UTF8.GetBytes(_fName); //file name byte[] fileData = File.ReadAllBytes(FilePath); //file byte[] fileNameLen = BitConverter.GetBytes(fileName.Length); //lenght of file name byte[] m_clientData = new byte[4 + fileName.Length + fileData.Length]; fileNameLen.CopyTo(m_clientData, 0); fileName.CopyTo(m_clientData, 4); fileData.CopyTo(m_clientData, 4 + fileName.Length); clientSock.Connect(AppConfigs.Load().ServerIP, _portSend); //target machine's ip address and the port number clientSock.Send(m_clientData); clientSock.Close(); }
public void ReadCallback(IAsyncResult ar) { pb.Invoke(new ReceiveDelegate(pbShow)); int fileNameLen = 1; String content = String.Empty; StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; int bytesRead = handler.EndReceive(ar); if (bytesRead > 0) { if (_flag == 0) { fileNameLen = BitConverter.ToInt32(state.buffer, 0); string fileName = Encoding.UTF8.GetString(state.buffer, 4, fileNameLen); _receivedPath = AppConfigs.Load().SavePath + "\\" + fileName; _flag++; } if (_flag >= 1) { BinaryWriter writer = new BinaryWriter(File.Open(_receivedPath, FileMode.Create)); if (_flag == 1) { writer.Write(state.buffer, 4 + fileNameLen, bytesRead - (4 + fileNameLen)); _flag++; } else { writer.Write(state.buffer, 0, bytesRead); } writer.Close(); handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); } } else { pb.Invoke(new ReceiveDelegate(pbHide)); } }