// Save the file path, including the file name
Private string GetSavePath (string FileName)
{
String path = Request. PhysicalApplicationPath + "\ Link_Icon ";
Return path + "\" + FileName;
}
Private bool UpLoad () // uploads an image
{
Bool flag = false;
String FileName = GetFileName (fileIcon. Value );
String db = Request. PhysicalApplicationPath + "\\# CommCcope. mdb ";
String constr = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" + db;
OleDbConnection con = new OleDbConnection (constr );
Try
{
// Upload a file
String SavePath = GetSavePath (FileName );
FileIcon. PostedFile. SaveAs (SavePath );
// Insert a database
OleDbCommand com = new OleDbCommand ("Insert into FriendLink (SiteName, DISPLAY, LINK) VALUES ('" + txtName. text + "','" + FileName + "','" + txtLink. text + "')", con );
Con. Open ();
Com. ExecuteNonQuery ();
Con. Close ();
Flag = true;
}
Catch (Exception ex)
{
Label1. Text = "error:" + ex. Message;
}
Finally
{
If (con. State! = 0) con. Dispose ();
}
Return flag;
}