I have a form which uploads the file after uploading the listview should be clear.
i have used clear method but it did not get clear.
string Resume = string.Empty;
string htmlresume = string.Empty;
string mail = string.Empty;
int hrid = 0;
string cont = string.Empty;
string cont1 = string.Empty;
string firstname = string.Empty;
string Middlename = string.Empty;
string lastname = string.Empty;
string read = "";
string htmlContents = "";
string dobs = "";
string filesdata;
List<HttpPostedFile> files = Session["Files"] as List<HttpPostedFile>;
try
{
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpf = files[i];
if (hpf.ContentLength > 0)
{
FileInfo fi = new FileInfo(hpf.FileName);
string ext = fi.Extension;
string sFileName = Path.GetFileName(hpf.FileName);
string sFileExt = Path.GetExtension(hpf.FileName);
sFileName = sFileName + "_" + DateTime.Now.Ticks;
sFileName = sFileName.Replace("@", "_");
sFileName = sFileName.Replace(".", "_");
sFileName = sFileName.Replace("/", "_");
sFileName = sFileName.Replace(" ", "_");
sFileName = sFileName.Replace(":", "_");
htmlresume = sFileName + "." + "html";
sFileName = sFileName + sFileExt;
var output = Regex.Replace(sFileName, @"[\d-]", string.Empty);
string[] splittedArray = output.Split(new char[] { ',', '_', '-', '.' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
if (splittedArray.Length >= 0)
{
firstname = splittedArray[0];
}
if (splittedArray.Length >= 1)
{
Middlename = splittedArray[1];
}
if (splittedArray.Length >= 2)
{
lastname = splittedArray[2];
}
//load file in folder
hpf.SaveAs(Server.MapPath("~/uploads/files/Documents/") + System.IO.Path.GetFileName(files[i].FileName));
string DT = System.DateTime.Now.ToShortDateString();
// Document parser code
aspose parser = new aspose();
parser.mail = mail;
if (mail != "")
{
//INSERT INTO HR_INFO TABLE
int rowAffected2 = DAL.InsertIntoPersonal_Info("7", "0", mail, firstname, Middlename, lastname, "1", "1", "1", "1", cont, cont1, DT, "Show");
}
else
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
File.Delete(Server.MapPath(Server.MapPath("~/uploads/files/Documents/") + System.IO.Path.GetFileName(files[i].FileName)));
}
}
}
}
catch (Exception)
{
throw;
}
Session.Clear();
Session.Abandon();
lstview.Items.Clear();
lstview.DataSource = null;