private void OnSaveAsSas(object sender, EventArgs e) { // Save the content of the friends data as a SAS program, // to the file system SaveFileDialog dlg = new SaveFileDialog(); if (me != null) { dlg.FileName = string.Format("Friends_of_{0}", me.Name.Replace(' ', '_')); } dlg.Filter = "SAS programs (.sas) | *.sas"; dlg.OverwritePrompt = true; dlg.CheckPathExists = true; if (DialogResult.OK == dlg.ShowDialog(this)) { try { // create and save the file string program = FacebookToSas.GetSasProgram(me, Friends, Schools, Statuses, FriendPairs, chkUnicode.Checked); System.IO.File.WriteAllText(dlg.FileName, program); MessageBox.Show(string.Format("Your SAS program has been saved to:\n\n {0}\n\nYou can open your program in SAS Enterprise Guide or SAS display manager and run PROCs on your Facebook friends!", dlg.FileName)); System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(dlg.FileName)); } catch { MessageBox.Show(string.Format("Unable to save file to: {0}", dlg.FileName)); } } }
public string GetSasProgram() { return(FacebookToSas.GetSasProgram(me, Friends, Schools, Statuses, FriendPairs, chkUnicode.Checked)); }