forum

Home / DeveloperSection / Forums / How to clone a HttpPostedFile

How to clone a HttpPostedFile

Anonymous User 2583 02-Jun-2015

I have an application that allows a user to upload a file, the file is scanned with Symantec protection engine before it is saved. The problem I'm encountering is that after the files are scanned with protection engine they have 0 bytes. I'm trying to come up with a solution to this problem. 

I've tried the cloning solution mentioned here: Deep cloning objects, but my uploaded files are not all Serializable. I've also tried resetting the stream to 0 in the scan engine class before passing it back to be saved. 

I have been in contact with Symantec and they said the custom connection class that was written for this application looks correct, and protection engine is not throwing errors. 

I'm open to any solution to this problem. 

Here is the code where the file is uploaded: 

private void UploadFiles()
            {                    System.Web.HttpPostedFile objFile;                    string strFilename = string.Empty;
                    if(FileUpload1.HasFile)
                    { 
                        objFile = FileUpload1.PostedFile;                        strFilename = FileUpload1.FileName;  
                        if (GetUploadedFilesCount() < 8)                        {
     if(IsDuplicateFileName(Path.GetFileName(objFile.FileName)) == false)                            {
    if(ValidateUploadedFiles(FileUpload1.PostedFile) == true)
         {
           //stores full path of folder
                string strFileLocation = CreateFolder();
 
             //Just to know the uploading folder
                                    mTransactionInfo.FileLocation = strFileLocation.Split('\\').Last();
    if(ScanUploadedFile(objFile) == true)
           {                                            SaveFile(objFile, strFileLocation);
            }
      else
                {                                       lblErrorMessage.Visible = true;
          if(mFileStatus != null)
              { lblErrorMessage.Text = mFileStatus.ToString(); }

I can provide the connection class code if anyone needs that, but it is quite large.


Updated on 02-Jun-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By