Public Sub DownloadDiagram(ByVal DiagramID As Integer)
Dim DatabaseName As String = "Diagrams"
Dim buffer As Byte() = Nothing
Dim sfilepath As String
Dim strsql As String
strsql = "SELECT Diagram FROM DAJobsDiagram WHERE DiagramID = '" & DiagramID & "'"
buffer = dhSQL.ExecuteScalar(DatabaseName, strsql)
sfilepath = System.IO.Path.GetTempFileName()
System.IO.File.Move(sfilepath, System.IO.Path.ChangeExtension(sfilepath, ".dwg"))
sfilepath = System.IO.Path.ChangeExtension(sfilepath, ".dwg")
System.IO.File.WriteAllBytes(sfilepath, buffer)
Dim act As Action(Of String) = New Action(Of String)(AddressOf OpenDiagramFile)
act.BeginInvoke(sfilepath, Nothing, Nothing)
End Sub
Private Sub OpenDiagramFile(ByVal sFilePath)
Using p As New System.Diagnostics.Process
p.StartInfo = New System.Diagnostics.ProcessStartInfo(sFilePath)
'I tried: p.StartInfo = New System.Diagnostics.ProcessStartInfo(appFile, sFilePath)
'where appFile = "C:\Program Files\Autodesk\DWG TrueView\dwgviewr.exe"
'It solves the problem of opening AutoCad, but it opens a new instance of TrueView each time.
'It's nice if TrueView opens once and multilple windows for different drawings.
p.Start()
p.WaitForExit()
System.IO.File.Delete(sFilePath)
End Using
End Sub
This post has been edited by AdamSpeight2008: 12 October 2012 - 04:31 PM

New Topic/Question
Reply



MultiQuote





|