Aspose.Tasks.Examples.CSharp.WorkingWithProjects.Miscellaneous.ExtractEmbeddedObjects.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:ExtractEmbeddedObjects
            Project project = new Project(dataDir + "ExtractEmbeddedObjects.mpp");
            OleObject ole = project.OleObjects.ToList()[0];

            // We have to check this property because it can be null if the embedded object was created inside the ms project application Or, alternatively, you can use this check: if (ole.FileFormat == "Package")
            if (!string.IsNullOrEmpty(ole.FullPath))
            {
                using (FileStream fileStream = new FileStream(dataDir, FileMode.Create))
                    fileStream.Write(ole.Content, 0, ole.Content.Length);
            }
            // ExEnd:ExtractEmbeddedObjects
        }
    }
ExtractEmbeddedObjects