Sunday, November 24, 2013

How to Use Sandbox Solution Code which is given in my BLOG

Usage  ex :-

FileStream stream = null;

            string sitecollectionUrl = "http://samplesitecollection:port";
            string UploadFileName = @"C:\HelloWorldSolution.wsp";


            FileInfo fileInfo = new FileInfo(UploadFileName);

            //Verifying the condition whether that file is existed (or) not
            if (!fileInfo.Exists) { throw new InvalidOperationException("The file does not exist."); }

            byte[] bytes = System.IO.File.ReadAllBytes(fileInfo.Name);

            //If file existed converting it in to the stream to transfer
            stream = File.OpenRead(UploadFileName);
            stream.Position = 0;


            //checking if the solution is uploaded in sitecollection solution gallery
            bool SolutionExits = CheckSolutionExits(sitecollectionUrl, fileInfo.Name);

           

            if (SolutionExits != true)
            {
                //add solution & activate
               bool SuccessDeployed = AddActivateSolutionbytes(sitecollectionUrl, fileInfo.Name, bytes);

            }

            if (SolutionExits == true)
            {
                //remove solution
                bool RemoveSuccess = RemoveSolution(sitecollectionUrl, fileInfo.Name);
            }

No comments:

Post a Comment