我使用SaveFileDialog和OpenFileDialog來保存我們的數(shù)據(jù)并重新打開它。我使用 write 命令來執(zhí)行此操作。我以txt格式保存所有數(shù)據(jù),但我想在數(shù)據(jù)之前進(jìn)行描述。我該怎么寫?private void Button_Click_1(object sender, RoutedEventArgs e){ SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == true) { using (StreamWriter write = new StreamWriter(File.Create(sfd.FileName))) { write.WriteLine(Sertifikasyon.Text); write.WriteLine(ACType.Text); write.WriteLine(FlightType.Text); write.WriteLine(Malzeme.Text); write.WriteLine(Motor.Text); write.WriteLine(Kcomp.Text); write.WriteLine(Wcrew.Text); write.WriteLine(Nseat.Text); write.WriteLine(Wbaggage.Text); write.WriteLine(Vs.Text); write.WriteLine(Vcr.Text); write.WriteLine(Vltr.Text); write.WriteLine(Vclmb.Text); write.WriteLine(R.Text); write.WriteLine(E.Text); write.WriteLine(Eclmb.Text); write.WriteLine(Ccr.Text); write.WriteLine(Cltr.Text); write.WriteLine(Cclmb.Text); write.WriteLine(LDcr.Text); write.WriteLine(LDltr.Text); write.WriteLine(LDclmb.Text); write.WriteLine(npcr.Text); write.WriteLine(npltr.Text); write.WriteLine(npclmb.Text); write.WriteLine(Runfuel.Text); write.WriteLine(Rresfuel.Text); write.Close(); write.Dispose(); } }}private void Button_Click_2(object sender, RoutedEventArgs e){ OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { using (StreamReader read = new StreamReader(File.OpenRead(ofd.FileName))) { Sertifikasyon.Text = read.ReadLine(); ACType.Text = read.ReadLine(); FlightType.Text = read.ReadLine(); } }}我想要標(biāo)題在值之前,例如:Crew Weight=82這里是txt輸出。
如何在一行中寫入多個(gè)字符串?
叮當(dāng)貓咪
2023-07-23 14:09:36