Hello commnunity.
I am trying to upload and save a file in DB, which i am not being able of. Can you tell what is wrong in my code?
//My upload file method protected void UploadSampleFile_Click(object sender, EventArgs e) { foreach (UploadedFile file in RadAsyncUploadSample.UploadedFiles) { RadAsyncUploadSample.Visible = false; UploadSampleFile.Visible = false; TemplateFile model = new TemplateFile(); model.FileNameT = Path.GetFileNameWithoutExtension(file.FileName); //obter o nome do ficheiro do cliente model.FileTipoT = Path.GetExtension(file.FileName); file.InputStream.Position = 0; model.FileContentT = new byte[file.InputStream.Length]; for (int totalBytesCopied = 0; totalBytesCopied < file.InputStream.Length; ) totalBytesCopied += file.InputStream.Read(model.FileContentT, totalBytesCopied, Convert.ToInt32(file.InputStream.Length) - totalBytesCopied); int IDTemplate = templatebll.SaveFile(model); //My BLL save file method public int SaveFile(TemplateFile model) { try { using (GestaoProjectosEntities lt = new GestaoProjectosEntities()) { lt.TemplateFiles.AddObject(model); lt.SaveChanges(); return model.IDTemplate; } } }