//open file stream using (StreamWriter file = File.CreateText(@"D:path.txt")) { JsonSerializer serializer = new JsonSerializer(); //serialize object directly into file stream serializer.Serialize(file, _data); }