Hello Aspose team,
in attached project you will find test application which has task to open MPP file (Project1.mpp), find task hyperlinks, make changes and save file under new name (output.mpp).
After I try to open this new file MS Project reports that it cannot be opened.
Am I doing something wrong?
Code is simple:
Private Sub ProcessProject(file As Object)
Try
Dim fi As FileInfo = New FileInfo(file.ToString)
OpenedProjectSize += fi.Length
OpenedProject += 1
Dim locCount As Boolean = False
'Dim fs As FileStream = New FileStream(file.ToString, FileMode.Open, FileAccess.ReadWrite)
Dim doc As Aspose.Tasks.Project = New Aspose.Tasks.Project(file.ToString)
Dim collector As Aspose.Tasks.Util.ChildTasksCollector = New Aspose.Tasks.Util.ChildTasksCollector()
Aspose.Tasks.Util.TaskUtils.Apply(doc.RootTask, collector, 0)
Dim hpl As String
For Each tsk As Task In collector.Tasks
hpl = tsk.Get(Aspose.Tasks.Tsk.Hyperlink)
If InStr(hpl, "task") <> 0 Then
hpl = hpl.Replace("task", "ASPOSE")
tsk.Set(Aspose.Tasks.Tsk.Hyperlink, hpl)
End If
tsk.Get(Aspose.Tasks.Tsk.HyperlinkAddress)
tsk.Get(Aspose.Tasks.Tsk.HyperlinkSubAddress)
Next
doc.Save("output.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP)
doc = Nothing
Catch ex As Exception
Dim exMsg As String = ex.Message
BadFilesCounter += 1
BadFiles = BadFilesCounter.ToString + ". " + BadFiles + "File: " + file + ", Error: " + exMsg + vbLf
End Try
End Sub
Btw. I have Project 2007 on my computer and document is created with it also.
Thanks in advance,
Oliver