Save As TXT

Source: Internet
Author: User

Open dialog box saved as txt

1   #region2              This. ddowntable = (DataTable) ( This. Dg1. DataContext);3             if( This. DDownTable.Rows.Count >0)4             {5                 stringFName =string. Empty;6System.Windows.Forms.SaveFileDialog SaveFileDialog =NewSystem.Windows.Forms.SaveFileDialog ();7Savefiledialog.filter ="TXT FIlE (*.txt) |*.txt";8Savefiledialog.filterindex =2;9Savefiledialog.restoredirectory =true;TenSavefiledialog.filename ="solarprotonevents"; One                 if(Savefiledialog.showdialog () = =System.Windows.Forms.DialogResult.OK) A                 { -FName =Savefiledialog.filename; -  the                     //Write File -StringBuilder SB =NewStringBuilder (); -                   //sb. Append ("SPE Start"). PadLeft (+) + "\t\tproton Flux Max Time". PadRight + "\ t Proton Flux Max". PadRight (+) + "Associated CME". PadRight + "\ t Flare Max time". PadRight (+) + "Flare Max". PadRight (+) + "location". PadRight + "region". PadRight (Ten) + "\r\n\r\n"); -  +  -Sb. Append ("# Prepared by Space Environment Prediction Center\r\n"+ +                       "# Please send comments and suggestions to [email protected]\r\n"+ A                       "#\r\n"+"# SPE Start:column 1-17, time when SPE started (UT), and the format is \ "Yyyy-mm-dd hh:mm\". \ r \ n"+ at                      "# Proton Flux Max time:column 26-42, time when the Proton flux reached the peak during the SPE, and the format is \ "Y Yyy-mm-dd hh:mm\ ". \ r \ n"+ -                       "# Proton Flux max:column 50-54, peak value of the Proton Flux during the spe.\r\n"+ -                       "# associated Cme:column 66-77, associated CME that could be possible cause of the spe.\r\n"+ -                       "# Flare Max time:column 82-98, time when the X-ray flux reached the peak, and the format is \ "Yyyy-mm-dd hh:mm\". \r\ N"+ -                       "# flare Max:column 106-110, flare class.\r\n"+ -                        "# Location:column 122-132, region location of the solar disk.\r\n"+ in                         "# region #: Column 138-142, Region number by swpc.\r\n\r\n" -                       ); to                     foreach(DataRow Drinchddowntable.rows) +                     { -Sb. Append (dr["Start"]. ToString (). PadRight ( -) ); theSb. Append (dr["Max"]. ToString (). PadRight ( -) ); *Sb. Append (dr["Proton"]. ToString (). PadRight ( -) ); $Sb. Append (dr["CME"]. ToString (). PadRight ( -) );Panax NotoginsengSb. Append (dr["Flare"]. ToString (). PadRight ( -) ); -Sb. Append (dr["Xray"]. ToString (). PadRight ( -) ); theSb. Append (dr[" Location"]. ToString (). PadRight ( -) ); +Sb. Append (dr[" Region"]. ToString () +"\ t"); A                         //sb. Append (dr["Imgkp1"). ToString () + "\ t"); the                         //sb. Append (dr["IMGKP2"). ToString () + "\ t"); +                         //sb. Append (dr["Time"). ToString () + "\ t"); -                         //sb. Append (dr["Xray1"). ToString () + "\ t"); $                         //sb. Append (dr["Xray2"). ToString () + "\ t"); $                         //sb. Append (dr["Proton1"). ToString () + "\ t"); -Sb. Append ("\ r \ n"); -                     } the Util.FileOperate.WriteFile (FName, sb.) ToString ()); -                 }Wuyi             } the             #endregion
1   #regionWrite a file2         /// <summary>3         ///Write a file4         /// </summary>5         /// <param name= "Path" >file path</param>6         /// <param name= "Strings" >File Contents</param>7          Public Static voidWriteFile (stringFilefullpath,stringStrings)8         {9             if(!System.IO.File.Exists (filefullpath))Ten             { OneSystem.IO.FileStream fs =System.IO.File.Create (filefullpath); A FS. Close (); -             } -System.IO.StreamWriter SW =NewSystem.IO.StreamWriter (Filefullpath,false, System.Text.Encoding.GetEncoding ("gb2312")); the SW. Write (Strings); - SW. Flush (); - SW. Close (); - SW. Dispose (); +         } -         #endregion

Save As TXT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.