// download the catalog entry contents and view in an editor private void ViewInEditor(string catEntry) { SAS.FileService fs = null; SAS.Fileref fr = null; SAS.Workspace ws = null; SAS.TextStream ts = null; string fileref; try { // use SAS workspace and fileservice to download the file ws = consumer.Workspace(currentServer) as SAS.Workspace; fs = ws.FileService; // using the FILENAME CATALOG access method fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref); ts = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500); ts.Separator = Environment.NewLine; string tempFn = System.IO.Path.GetTempFileName(); // downloading catalog entry contents to local temp file using (System.IO.StreamWriter sw = System.IO.File.CreateText(tempFn)) { int lines = 1; Array truncLines, readLines; // iterate through until all lines are read in while (lines > 0) { ts.ReadLines(100, out truncLines, out readLines); lines = readLines.GetLength(0); for (int i = 0; i < lines; i++) { sw.WriteLine(readLines.GetValue(i)); } } sw.Close(); } EEFileViewer dlg = new EEFileViewer(tempFn); dlg.Text = catEntry.ToUpper(); dlg.Icon = new Icon(typeof(Global), "icons.entry.ico"); // show modal dialog with editor dlg.ShowDialog(); // clean up System.IO.File.Delete(tempFn); } catch (Exception ex) { MessageBox.Show(string.Format("Cannot open the catalog entry {0}. Reason: {1}", catEntry, ex.Message)); } }
// download the catalog entry contents and view in an editor private void ViewInEditor(string catEntry) { SAS.FileService fs = null; SAS.Fileref fr = null; SAS.Workspace ws = null; SAS.TextStream ts = null; string fileref; try { // use SAS workspace and fileservice to download the file ws = consumer.Workspace(currentServer) as SAS.Workspace; fs = ws.FileService; // using the FILENAME CATALOG access method fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref); ts = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500); ts.Separator = Environment.NewLine; string tempFn = System.IO.Path.GetTempFileName(); // downloading catalog entry contents to local temp file using(System.IO.StreamWriter sw = System.IO.File.CreateText(tempFn)) { int lines = 1; Array truncLines, readLines; // iterate through until all lines are read in while (lines>0) { ts.ReadLines(100, out truncLines, out readLines); lines = readLines.GetLength(0); for (int i=0; i<lines; i++) sw.WriteLine(readLines.GetValue(i)); } sw.Close(); } EEFileViewer dlg = new EEFileViewer(tempFn); dlg.Text = catEntry.ToUpper(); dlg.Icon = new Icon(typeof(Global), "icons.entry.ico"); // show modal dialog with editor dlg.ShowDialog(); // clean up System.IO.File.Delete(tempFn); } catch (Exception ex) { MessageBox.Show(string.Format("Cannot open the catalog entry {0}. Reason: {1}", catEntry, ex.Message)); } }