Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.IO;
- using System.Windows.Forms;
- using System.Net;
- using System.Data;
- using System.ComponentModel;
- namespace FTPHound
- {
- class SettingsManagement
- {
- BinaryFormatter formatter = new BinaryFormatter();
- FileStream stream;
- public void LoadSettings(Settings setting)
- {
- stream = new FileStream("settings.dat", FileMode.OpenOrCreate);
- if (stream.Length > 0)
- {
- setting = (Settings)formatter.Deserialize(stream);
- //MessageBox.Show(settings.teststr.GetType().ToString() + ", " + settings.teststr.Length + ", " + settings.teststr);
- }
- }
- public void SaveSettings(Settings settings)
- {
- formatter.Serialize(stream, settings);
- }
- public void InitDraw(Settings settings) //For when the program first loads up.
- {
- if (settings.serverlist.Count > 0)
- {
- for (int i = 0; i <= settings.serverlist.Count; i++)
- {
- settings.serverlist.Add(settings.serverlist[i]);
- }
- }
- }
- }
- [Serializable]
- class Settings
- {
- public BindingList<ServerSetting>serverlist = new BindingList<ServerSetting>();
- }
- [Serializable]
- public struct ServerSetting
- {
- public string CustomName;
- public IPAddress hostaddress;
- public string localdirectory;
- public string remotedirectory;
- public string login;
- public string password;
- public ServerSetting(string customname, IPAddress hostaddr, string localdir, string remotedir, string user, string pass)
- {
- CustomName = customname;
- hostaddress = hostaddr;
- localdirectory = localdir;
- remotedirectory = remotedir;
- login = user;
- password = pass;
- }
- new public string ToString()
- {
- return "CustomName: " + CustomName + "; HostAddress: " + hostaddress + "; LocalDirectory: " + localdirectory + "; RemoteDirectory: " + remotedirectory + "; Username: " + login + "; Password: " + password;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement