How to open a file
<p>In my project I am trying to open a file. I am storing all the path of the file name along with extensions like .exe,.doc,.xml,etc.....in my database. I am fetching that path and trying to open it.In this I like to open it as a popup window to ask like OPEN,SAVE,CANCEL . Can any one help me to solve this problem. Here is the code:</p>

<pre><code>private void OpenMyFile()
{
    string path = GetPath() + ViewState["fileopen"];
    FileInfo file = new FileInfo(ViewState["fileopen"].ToString());
    SqlConnection con = new SqlConnection(@"server=servername;database=DBNAME;uid=ID;pwd=PWD;max pool size=250;Connect Timeout=0");
    con.Open();
    cmd = new SqlCommand("select * from filetypemaster where extension='" + file.Extension + "'", con);
    myReader = cmd.ExecuteReader();


    if (myReader.Read())
    {
        Response.ContentType =(String)myReader["CONTENT_TYPE"];
        myReader.Close();

    }
    else
    {
        myReader.Close();
        Message("Cannot open selected file");
        return;
    }

    Response.WriteFile(path);
    Response.End();

    con.Close();
}
</code></pre>

<p>Thanks in advance</p>
