Message 1 of 13
Not applicable
03-26-2012
12:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Need some help here:
Any clue why I'm getting this error?
Sub LoopThroughFolderOfDwgsAndUpdateHyperlinks()
Dim myCounter As Integer = 0
' First create a FolderBrowserDialog object
Dim FolderBrowserDialog1 As New FolderBrowserDialog
' Then use the following code to create the Dialog window
' Change the .SelectedPath property to the default location
With FolderBrowserDialog1
' Desktop is the root folder in the dialog.
.RootFolder = Environment.SpecialFolder.Desktop
' Select the C:\Windows directory on entry.
.SelectedPath = "Q:\"
If .ShowDialog = DialogResult.OK Then
' Display the selected folder if the user clicked on the OK button.
Dim files() As String = Directory.GetFiles(.SelectedPath, "*.dwg", SearchOption.TopDirectoryOnly)
For Each file In files
'do code to files
If (System.IO.File.Exists(file.ToString)) Then
'Try
'Create Database Object to Store Drawing Info into
Dim myDB As New DatabaseServices.Database
'Read Drawing File
myDB.ReadDwgFile(file, FileOpenMode.OpenForReadAndWriteNoShare, False, "")
'TODO: Error Catching for files already opened...
'UPDATE THE HYPERLINKS IF FILE OPENS
UpdateHyperlinksInDocument(myDB)
'Processed File Count
myCounter = myCounter + 1
'!!!!!!!!!!ERRROR ON THIS LINE "myDB.SaveAs"
'Save Drawing
myDB.SaveAs(file, False, DwgVersion.Current, myDB.SecurityParameters)
'File Processed Successfully
gsFileSuccessList.Add(file)
'Clean-up Memory Object
myDB.Dispose()
'Catch ex As Exception
' Debug.Print(ex.Message & "On file:" & file)
' gsFileErrorList.Add(file)
'End Try
Else
Debug.Print("Can't Find and Open File : " & file)
gsFileErrorList.Add(file)
End If
Next
End If
End With
MsgBox("Processed: [" & myCounter & "] AutoCad files" & vbCrLf & _
"Succesfully Added: [" & gintHyperlinkCounter & "] hyperlinks")
If gsFileSuccessList.Count > 0 Then
Dim sFileList As String = String.Empty
For i = 0 To gsFileSuccessList.Count - 1
sFileList = sFileList + (gsFileSuccessList.Item(i) & vbCrLf)
Next
MsgBox("Successfully processed the following files: " & vbCrLf & _
sFileList)
End If
If gsFileErrorList.Count > 0 Then
Dim sFileList As String = String.Empty
For i = 0 To gsFileErrorList.Count - 1
sFileList = sFileList + (gsFileErrorList.Item(i) & vbCrLf)
Next
MsgBox("Couldn't Process the following files: " & vbCrLf & _
sFileList)
End If
End Sub
Solved! Go to Solution.

