public void Read(string filepath) { this._filename = filepath; string data = string.Empty; using (StreamReader reader = new StreamReader(filepath)) { data = reader.ReadToEnd(); } string[] settings = data.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string thisSetting in settings) { string regex = "(?<type>.*)\\:(?<dtype>\\w)\\:(?<value>.*)"; RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase); Regex reg = new Regex(regex, options); if (reg.IsMatch(thisSetting)) { Match m = reg.Match(thisSetting); string v = m.Groups["value"].Value; switch (m.Groups["type"].Value) { case "screen mode id": this._screenMode = int.Parse(v); break; case "desktopwidth": this._desktopWidth = int.Parse(v); break; case "desktopheight": this._desktopHeight = int.Parse(v); break; case "session bpp": this._sessionBPP = (SessionBPPs)int.Parse(v); break; case "winposstr": string[] vals = v.Split(','); this._winPosStr.WinState = (WindowState)int.Parse(vals[1]); this._winPosStr.Rect.Top = int.Parse(vals[2]); this._winPosStr.Rect.Left = int.Parse(vals[3]); this._winPosStr.Rect.Width = int.Parse(vals[4]); this._winPosStr.Rect.Height = int.Parse(vals[5]); break; case "full address": this._fullAddress = v; break; case "compression": this._compression = int.Parse(v); break; case "keyboardhook": this._keyboardHook = (KeyboardHooks)int.Parse(v); break; case "audiomode": this._audiomode = (AudioModes)int.Parse(v); break; case "redirectdrives": this._redirectDrives = int.Parse(v); break; case "redirectprinters": this._redirectPrinters = int.Parse(v); break; case "redirectcomports": this._redirectComPorts = int.Parse(v); break; case "redirectsmartcards": this._redirectSmartCards = int.Parse(v); break; case "displayconnectionbar": this._displayConnectionBar = int.Parse(v); break; case "autoreconnection enabled": this._autoReconnectionEnabled = int.Parse(v); break; case "username": this._username = v; break; case "domain": this._domain = v; break; case "alternate shell": this._alternateShell = v; break; case "shell working directory": this._shellWorkingDirectory = v; break; case "password 51": this._password = v; break; case "disable wallpaper": this._disableWallpaper = int.Parse(v); break; case "disable full window drag": this._disableFullWindowDrag = int.Parse(v); break; case "disable menu anims": this._disableMenuAnims = int.Parse(v); break; case "disable themes": this._disableThemes = int.Parse(v); break; case "disable cursor setting": this._disableCursorSettings = int.Parse(v); break; case "bitmapcachepersistenable": this._bitmapCachePersistEnable = int.Parse(v); break; } } } }