my requirement is in a default page, for login,there r 3 fields as userid,password n state(which is in a dropdown form).By default,all the texttexts of india should be displayed.so,when a user l choose any state,while login,he can see all the details of tht particular state,after going thro' each page.
for that, i hav e created one folder named as StateFiles which is common for all state folders,in each statefolders,the required text files r there.i have used the session,bt its showing exception,tht System.IO.DirectoryNotFoundException: Could not find a part of the path 'I:\IRSAssociation\StateFiles\AndhraPradesh.txt\Co ntactUs.txt'.
bt,actually i need the path to be 'I:\IRSAssociation\StateFiles\AndhraPradesh\Contac tUs.txt'. for the text to be displayed in ContactUs page
here m sending my code.
public partial class _Default : System.Web.UI.Page
{
string filePath = "StateFiles";
protected void Page_Load(object sender, EventArgs e)
{
Session["State"] = "State";
if (!Page.IsPostBack)
{
System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath("India/India.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();
}
//GetMeetingsDetails();
//GetNewsDetails();
}
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
Session["State"] = ddlState.SelectedValue.ToString() + ".txt";
System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath(filePath + "/" + ddlState.SelectedValue.ToString() + "/" + "Default.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();
}
protected void ibLogin_Click1(object sender, ImageClickEventArgs e)
{
MySqlConnection myConnection = new MySqlConnection(Details.GetConnectionString());
try
{
MySqlCommand myCommand = new MySqlCommand("usp_ValidateLogin", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new MySqlParameter("?pUserId", MySqlDbType.VarChar)).Value = Convert.ToString(txtUserName.Text);
myCommand.Parameters.Add(new MySqlParameter("?pPassword", MySqlDbType.VarChar)).Value = Convert.ToString(txtPassword.Text);
DataSet dsUser = new DataSet();
MySqlDataAdapter mySqldaUser = new MySqlDataAdapter();
myConnection.Open();
mySqldaUser.SelectCommand = myCommand;
mySqldaUser.Fill(dsUser);
if (dsUser.Tables[0].Rows.Count != 0)
{
Session["user"] = txtUserName.Text.Trim();
Session["Login"] = "yes";
Response.Redirect("~/Main.aspx", false);
}
else
{
lblMessage.Visible = true;
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
myConnection.Close();
}
//if (Session["State"].ToString() == "State")
string strState = Session["State"].ToString();
System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath(filePath + "/" + strState + "/" + "ContactUs.txt"));
ltrMsg.Text = StreamReader1.ReadToEnd();
StreamReader1.Close();
}