The ajax file upload i used from ajax control toolkit is a multiuploader , i want to retrieve the number of files being uploaded . i tried this code here :
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { String pathdirectory = (Session["StoryPath"].ToString() + "/"); // selected item. EnsureDirectoriesExist(pathdirectory); String filepathImage = @"Story/" + pathdirectory; HttpFileCollection uploads = HttpContext.Current.Request.Files; for (int i = 0; i < uploads.Count ; i++) { int k = 0; int j = 0; if (j > 8) { j = 0; k += 1; } string total = k.ToString() + j.ToString(); AjaxFileUpload1.SaveAs(Server.MapPath(filepathImage + (total+ e.FileName))); j++; }
Because i want to rename every file which is uploaded like this : 00file.jpg , 01file.jpg , 02file.jpg and so on ... for now , the above code rename every file with 00 infront instead of increment in each file .. i guess i think i need to count the number of files being uploaded and rename them 1 by 1 in a loop but i duno if i am doing this in the correct way ( see above code ) , i am new to c# and ajax , hope experts here can guide me and provide me some help ! thanks