Files
Samuele Locatelli 12be248182 rename progetto...
2013-10-04 08:50:57 +02:00

51 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using NLog;
using ETS_Data;
namespace ETS_WS.WebUserControls
{
public partial class mod_fileUpload : System.Web.UI.UserControl
{
public event EventHandler eh_fileCaricato;
protected Logger lg;
protected void Page_Load(object sender, EventArgs e)
{
lg = LogManager.GetCurrentClassLogger();
}
/// <summary>
/// completato upload file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void fileUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string path = WebShipUtils.mng.UserTempPath;
// ora il file...
try
{
if (path != "")
{
// carico path e file
path = string.Format("{0}/{1}", path, System.IO.Path.GetFileName(e.FileName));
fileUpload.SaveAs(MapPath(path));
lg.Info("salvato file: {0}, {1:#.0} Kb", path, (double)e.FileSize / 1024);
if (eh_fileCaricato != null)
{
eh_fileCaricato(this, new EventArgs());
}
}
}
catch (Exception exc)
{
lg.Info("errore salvataggio: {0}", exc);
}
}
}
}