For a custom control, why does a relative path point to the Visual Studio Program Files directory?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
When within the designer, why does a relative path for a custom control reference the Visual Studio Program Files directory? I have a custom control in my application which logs to a particular folder. If the folder is not there, it is created. When I attempt
to add the custom control to a form I receive an exception stating that the directory cannot be accessed. A try-catch within the controls constructor shows that it is attempting to create the folder within "C:Program Files (x86)Microsoft Visual Studio 9.0Common7".
This occurs while viewing the designer, not at runtime.
I am guess that this is related to the fact that the custom controls constructor is being called when it gets added to a form at design time. However I do not understand why the constructor is called and how to fix the issue (by looking instead at the current
location of the projects executable). Any suggestions/clues would be greatly appreciated. Thanks.

View the full article
 
Back
Top