using System.IO;
using ImageGear.Formats;
using ImageGear.Formats.CAD;
publicstaticvoid LoadACadFile(string path)
{
ImGearCADPage page = null;
// Load the file.
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
page = (ImGearCADPage)ImGearFileFormats.LoadPage(fileStream);
}
}
VBV.NET
Copy Code
Imports System.IO
Imports ImageGear.Formats
Imports ImageGear.Formats.CAD
Public Sub LoadACadFile(path As String)
Dim page As ImGearCADPage
' Load the file.
Using fileStream As New FileStream(path, FileMode.Open, FileAccess.Read)
page = ImGearFileFormats.LoadPage(fileStream)
End Using
End Sub
Loading a Password Protected DWG File
Loading a password protected DWG file is similar to loading any other CAD file.
using System.IO;
using ImageGear.Formats;
using ImageGear.Formats.CAD;
publicstaticvoid LoadAPasswordProtectedDwg(string path, string password)
{
ImGearCADPage page = null;
// Set the password parameter to the password of the file.
IImGearFormat format = ImGearFileFormats.Filters.Get(ImGearFormats.DWG);
format.Parameters.GetByName("Password").Value = password;
// Load the file.
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
page = (ImGearCADPage)ImGearFileFormats.LoadPage(fileStream);
}
}
VB.NET
Copy Code
Imports System.IO
Imports ImageGear.Formats
Imports ImageGear.Formats.CAD
Public Sub LoadAPasswordProtectedDwg(path As String, password As String)
Dim page As ImGearCADPage
' Set the password parameter to the password of the file.
Dim format = ImGearFileFormats.Filters.Get(ImGearFormats.DWG)
format.Parameters.GetByName("Password").Value = password
' Load the file.
Using fileStream As New FileStream(path, FileMode.Open, FileAccess.Read)
page = ImGearFileFormats.LoadPage(fileStream)
End Using
End Sub