Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Fileupload: resize image

$
0
0

I use below method to upload Picture to CRM 2011 Online 

Can anyone point me in right direction on how i can resize the image to save disk space

 

 if (FileUploadFormbilde.HasFile)
            {

                Annotation note = new Annotation();


                Guid testGUID2 = new Guid(testGUID.ToString());
                EntityReference entRef = new EntityReference("new_test", testGUID2);


                string strFileName = FileUploadFormbilde.PostedFile.FileName;
                Stream fStream = FileUploadFormbilde.PostedFile.InputStream;
                byte[] binFile = new byte[FileUploadFormbilde.PostedFile.ContentLength];
                fStream.Read(binFile, 0, binFile.Length);
                fStream.Close();

                note.Subject = "Test";
                note.FileName = strFileName;
                note.DocumentBody = Convert.ToBase64String(binFile);
                note.MimeType = GetContentType(strFileName);
                note.ObjectId = entRef;
                orgContext.Create(note);
            }

            Response.Redirect("../Pages/bekreftelse.htm");

            /////////////////      

           
        }

        private string GetContentType(string fileName)
        {
            string contentType = "application/octetstream";
            string ext = System.IO.Path.GetExtension(fileName).ToLower();
            Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
        if (registryKey != null && registryKey.GetValue("Content Type") != null)
            contentType = registryKey.GetValue("Content Type").ToString();
            return contentType;

        }

 

CRM Consultant/Business Advisor at Skill AS in Norway
RockStar365 profile




Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>