private void translateButton_Click(object sender, RoutedEventArgs e) { string idir = @"C:\Documents and Settings\fleminbr\Desktop\temp\BIAR Code Tables\"; string odir = @"C:\Documents and Settings\fleminbr\Desktop\temp\BIAR ascii tables\"; foreach (var dir in Directory.GetFiles(idir, "*out")) { FileInfo di = new FileInfo(dir); string temp = di.Name; string dat = di.FullName.Replace(".out", ".dat"); string asc = di.Name.Replace(".out", ".cvs"); recordTextBox.Text += temp + Environment.NewLine; FadePlus.FadePlus nfp = new FadePlus.FadePlus(di.FullName); if (nfp == null) { warningTextBox.Text += "\nCould not load template\n"; return; } nfp.RightEnd = ""; nfp.LeftEnd = ""; nfp.ShowAscii = false; nfp.ShowEnds = false; // load all records and Read the first if (!nfp.AddDataFile(dat)) { warningTextBox.Text += "\n Could not load data file" + dat + "\n"; continue; } FileStream fs = new FileStream(odir + asc, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); for (int i = 1; i <= nfp.RecordCount; i++) { string commastring = nfp.GetRecord(i, true); sw.WriteLine(commastring); } sw.Close(); fs.Close(); } }
private void loadButton_Click(object sender, RoutedEventArgs e) { // Parse Mask fp = new FadePlus.FadePlus(maskFP); fp.Warning += new WarningEventHandler(fp_Warning); fp.RightEnd = rightEndTextBox.Text; fp.LeftEnd = leftEndTextBox.Text; fp.ShowEnds = (bool)endsCheckBox.IsChecked; fp.ShowAscii = (bool)asciiCheckBox.IsChecked; if (fp == null) { warningTextBox.Text += "\nCould not load template\n"; return; } // load all records and Read the first if (!fp.AddDataFile(dataFP)) { warningTextBox.Text += "\n Could not load data file\n"; return; } this.Title = "Fade.Plus - " + new FileInfo(dataFP).Name; // populate the search field drop down searchFieldComboBox.Items.Clear(); foreach (var field in fp.RecordTemplate.GetSearchFields()) { searchFieldComboBox.Items.Add(field); } // Display the details recordSizeLabel.Content = fp.RecordTemplate.RecLength.ToString(); recordInfoLabel.Content = "/" + fp.RecordCount; maskTextBox.Text = fp.RecordTemplate.TemplateToString(); fp.RecordChange += new RecordChangeEventHandler(RecordChange); fp.GetRecord(1); }
private void translateButton_Click(object sender, RoutedEventArgs e) { string idir = @"C:\Documents and Settings\fleminbr\Desktop\temp\BIAR Code Tables\"; string odir = @"C:\Documents and Settings\fleminbr\Desktop\temp\BIAR ascii tables\"; foreach ( var dir in Directory.GetFiles(idir, "*out")) { FileInfo di = new FileInfo(dir); string temp = di.Name; string dat = di.FullName.Replace(".out", ".dat"); string asc = di.Name.Replace(".out", ".cvs"); recordTextBox.Text += temp + Environment.NewLine; FadePlus.FadePlus nfp = new FadePlus.FadePlus(di.FullName); if (nfp == null) { warningTextBox.Text += "\nCould not load template\n"; return; } nfp.RightEnd = ""; nfp.LeftEnd = ""; nfp.ShowAscii = false; nfp.ShowEnds = false; // load all records and Read the first if (!nfp.AddDataFile(dat)) { warningTextBox.Text += "\n Could not load data file" + dat + "\n"; continue; } FileStream fs = new FileStream(odir + asc, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); for (int i = 1; i <= nfp.RecordCount; i++) { string commastring = nfp.GetRecord(i, true); sw.WriteLine(commastring); } sw.Close(); fs.Close(); } }