Here it is in C#.
using System;
using System.Windows.Forms;
using Autodesk;
using Autodesk.AutoCAD.ApplicationServices;
using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.Interop;
namespace TID_
{
public class Helper
{
private void AppendSupportPath(string FilePath)
{
try
{
AcadApplication app = acApp.AcadApplication;
AcadPreferencesFiles files = app.Preferences.Files;
string[] ary = files.SupportPath.Split(';');
bool bln = false;
// Check to see if its already added.
foreach (String Str in ary)
{
if (Str == FilePath)
{
bln = true;
};
};
// If not, add it.
if (bln == false)
{
files.SupportPath = files.SupportPath + ";" + FilePath;
};
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show("Error Occured in AppendSupportPath. " + ex.Message + ", ", "AppendSupportPath Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void PrependSupportPath(string FilePath)
{
try
{
AcadApplication app = acApp.AcadApplication;
AcadPreferencesFiles files = app.Preferences.Files;
string[] ary = files.SupportPath.Split(';');
bool bln = false;
// Check to see if its already added.
foreach (String Str in ary)
{
if (Str == FilePath)
{
bln = true;
};
};
// If not, add it.
if (bln == false)
{
files.SupportPath = files.SupportPath = FilePath + ";" + files.SupportPath;
};
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show("Error Occured in PrependSupportPath. " + ex.Message + ", ", "PrependSupportPath Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Ed
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to
post your code.