Appending JSON file
This commit is contained in:
parent
a08b729982
commit
755ffa610f
|
@ -6,4 +6,8 @@
|
|||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql" Version="5.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Button x:Name="saveButton" Content="Save" HorizontalAlignment="Left" Margin="400,0,0,173" VerticalAlignment="Bottom" Height="216" Width="349" Click="saveButton_Click"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -12,6 +12,9 @@ using System.Windows.Media;
|
|||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace CryptoCalc
|
||||
{
|
||||
|
@ -20,10 +23,41 @@ namespace CryptoCalc
|
|||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly Random rand = new();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
//asdf
|
||||
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Debug.WriteLine("asdf");
|
||||
|
||||
|
||||
var weatherForecast = new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Parse("2019-08-01"),
|
||||
TemperatureCelsius = rand.Next(0,100),
|
||||
Summary = "Hot"
|
||||
|
||||
};
|
||||
|
||||
string fileName = "asdf.json";
|
||||
string jsonString = JsonSerializer.Serialize(weatherForecast);
|
||||
File.AppendAllText(fileName, jsonString);
|
||||
|
||||
Debug.WriteLine(File.ReadAllText(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTimeOffset Date { get; set; }
|
||||
public int TemperatureCelsius { get; set; }
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue