i want to ask how to open specific file (the file out of the server, i have a relative path to it stored in config file) with its application when click on specific link button or hyper link...
like ::
open .docx with word.
or .pdf with acrobat reader
i tried several methods but , i get different errors like
"Cannot use a leading .. to exit above the top directory"
this my code::
public void ProcessRequest(HttpContext context)
{
int newsId = int.Parse(context.Session["newsId"].ToString());
int FK_UnitId = int.Parse(context.Session["UserData"].ToString());
string dirPathForTextFiles = ConfigurationManager.AppSettings.GetValues("ThePath").First() + "/" + "NewsTextFiles" + "/" + "UnitNum" + FK_UnitId.ToString() + "_" + "NewsNum" + newsId + "/";
DataTable UpdatedDateTable = (DataTable)context.Session["theLastUpdatedTextFile"];
UpdatedDateTable.AcceptChanges();
context.Session.Add("currentTextFile", UpdatedDateTable);
List<string> l = new List<string>(UpdatedDateTable.Rows.Count);
try
{
l.Add(dirPathForTextFiles + UpdatedDateTable.Rows[0]["fileName"].ToString());
context.Response.ContentType = getContentType(dirPathForTextFiles + UpdatedDateTable.Rows[0]["fileName"].ToString());
System.Diagnostics.Process.Start(l[0]);
context.ClearError();
}
catch (IOException e)
{
string message = e.Message;
}
}
string getContentType(String path)
{
switch (Path.GetExtension(path))
{
case ".doc": return " application/msword";
case ".docx": return "application/msword";
case ".pdf": return "application/pdf";
default: break;
}
return "";
}`