Question: C# Programming Create a Web application that enables the user to enter first name, last name, and e-mail address. Accept those values and store them
C# Programming
Create a Web application that enables the user to enter first name, last name, and e-mail address. Accept those values and store them in a text file. Allow the user to input the path where the file should be stored. After retrieving the values from the user, display on the Web page both the full file path (including the name of the file) and all values stored in the file. Confirm that the values are written to the file.
This is what I have so far, however im getting many errors for this project
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace E_Mail_PRoject { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { messagelbl.Visible = false; contentlbl.Visible = false; } protected void Savebtn_Click(object sender, EventArgs e) { // create string path for creating file string path = @pathbox.Text;
// try block to check for inaccessible path try { if (!Directory.Exists(path))
// checks weather a directory exist or not { // if directory is not exist the it create//file Directory.CreateDirectory(path); } // write user data at specified path
File.WriteAllText(path.Combine(path, fnamebox.Text + ".txt"), lnamebox.Text + " " + emailbox.Text); // make message label visible messagelbl.Visible = true;
//change message label color to Green messagelbl.ForeColor = System.Drawing.Color.Green;
//make message label text bold messagelbl.Font.Bold = true;
//print message messagelbl.Text = "Data save in" + fnamebox.Text + ".txt at the location" + path;
//checking that the file is created and reading the contents string[] data = (File.ReadAllText(path + "\\" + fnamebox.Text + ".txt")).Split('');
//make contentlbl text bold contentlbl.Font.Bold = true;
//make contentlbl visible contentlbl.Text = "First Name: " + data[0] + "Last Name: " + data[1] + "Email Address: " + data[2]; } catch { //make messagelbl visible messagelbl.Visible = true;
//change font to red color messagelbl.ForeColor = System.Drawing.Color.Red;
//print message messagelbl.Text = "Path is inaccessible"; } } } }
Here are the errors im stuck on
This is the way the interface looks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
