public FifoReadWrite FifoReadOpen(FifoReadWrite myFRW, string deviceName) { Stream stream; XmlDocument document = new XmlDocument(); OpenFileDialogComment comment = new OpenFileDialogComment { Filter = "WDS files (*.swc)|*.swc|All files (*.*)|*.*" }; if ((comment.ShowDialog() == DialogResult.OK) && ((stream = new FileStream(comment.FileName, FileMode.Open, FileAccess.Read)) != null)) { MemoryStream stream2 = new MemoryStream(); TextWriter writer = new StreamWriter(stream2); TextReader reader = new StreamReader(stream); writer.Write(Code.EncryptDecrypt(reader.ReadToEnd())); writer.Flush(); stream2.Seek(0L, SeekOrigin.Begin); document.Load(stream2); document.PreserveWhitespace = false; XmlNode documentElement = document.DocumentElement; this.RestoreFifoRead(documentElement, myFRW, deviceName); } return myFRW; }
public int Openconfig(string ChipRevForConfig) { try { this._actFileName = ""; this._configNode = null; XmlDocument document = new XmlDocument(); OpenFileDialogComment comment = new OpenFileDialogComment { Filter = "WDS files (*.swc)|*.swc|All files (*.*)|*.*", FileName = Path.Combine(this._appDataDir, "*.swc") }; if (comment.ShowDialog() == DialogResult.OK) { if ((this._appDataDir != "") && !this.CheckFolderChange(comment.FileName)) { this._appDataDir = ""; } this._actFileName = comment.FileName; document.Load(this._actFileName); document.PreserveWhitespace = false; this._configNode = document.GetElementsByTagName(ChipRevForConfig)[0]; return 0; } return -2; } catch (Exception exception) { GlobalServices.ErrMsg(ChipRevForConfig, "Error at loading Device settings! \n" + exception.Message); GlobalServices.msgBox("Error at loading Device settings! \n" + exception.Message, "Error!"); return -3; } }
public int ScriptOpen(ref List<string> ScriptList) { string currentDirectory = Directory.GetCurrentDirectory(); OpenFileDialogComment comment = new OpenFileDialogComment { Title = "Open Batch File", Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*", FileName = Path.Combine(this._appDataDir, "*.txt") }; DialogResult result = comment.ShowDialog(); Directory.SetCurrentDirectory(currentDirectory); if ((result == DialogResult.OK) && (comment.FileName != null)) { if ((this._appDataDir != "") && !this.CheckFolderChange(comment.FileName)) { this._appDataDir = ""; } FileStream stream = new FileStream(comment.FileName, FileMode.Open, FileAccess.Read); TextReader reader = new StreamReader(stream); string item = ""; while ((item = reader.ReadLine()) != null) { ScriptList.Add(item); } stream.Close(); } return 0; }