private void addRecipeBtn_Click(object sender, EventArgs e) { string title = titletxtbox.Text; string author = authortxtbox.Text; string date = datetxtbox.Value.ToString("yyyy-MM-dd"); string desc = desctxtbox.Text; string url = urltextbox.Text; List <string> categories = new List <string>(); foreach (var item in categoriesList.SelectedItems) { categories.Add(item.ToString()); } Image recipe_thubmnail = pictureView.Image; var recipe_thubmnail_stream = new MemoryStream(); recipe_thubmnail.Save(recipe_thubmnail_stream, ImageFormat.Png); recipe_thubmnail_stream.Position = 0; if (this_recipe == null) { myServer.addRecipe(title, author, date, url, desc, categories.ToArray()); } else { myServer.updateRecipe(this_index.ToString(), title, author, date, url, desc, categories.ToArray()); } OnAddRecipeBtnClick(); this.Hide(); }