Moving Files Using the Component Manager

2 minute read time.
The component manager allows us to deliver not only Meta Data changes to a system but to also drop in and manage files like new logos, icons, and ASP files.

This article will cover the methods
  • CopyASPTo()
  • CreateNewDir();

Syntax: CopyAspTo(SourceFileName As String, TargetFileName As String)

  • CopyAspTo('\\project.gif', '\\img\\icons\\project.gif');
  • CopyASPTo('mycustomfile.js','custompages\\mycustomfile.js');

The Source file is assumed to be in the CustomPages folder underneath the components folder within the INF folder. The file can then be copied to any location under the wwwroot folder of the install. See the diagram below.

If you are not used to working with strings in JScript then it may seem strange that the path is written like:


The double backslash \\ is an example of an Escape character. Escape characters are special characters that allow you to include in strings some characters you cannot type directly. Each of these characters begins with a backslash. The backslash is an escape character you use to inform the JScript interpreter that the next character is special.

Other examples of Escape characters are

\' Single quotation mark
\" Double quotation mark


When we move the files we can also create a new folder as our target. This uses the CreateNewDir() method.

Syntax: CreateNewDir(DirName As String)


CreateNewDir(GetDLLDir() + '\\CustomPages\\project');

This would create a folder called project underneath the CustomPages folder. The method GetDLLDir() returns the directory path containing the DLL e.g. c:\program files\sage\crm\crm\wwwroot.

There is a second method called GetInstallDir() that returns the directory path containing the root of the installation e.g. C:\Program Files\Sage\CRM\CRM

We can put all this together in this example:

var DLLDir = GetDLLDir();\\Get WWWRoot location for output location
var CustomPagesDir = DLLDir + '\\CustomPages\\';
var ImagesDir = DLLDir + '\\Img\\';
\\ append img folder to wwwroot location for IMG OUTPUT Directory
CopyAspTo('Company\\PersonPhoneRedirect.asp', CustomPagesDir +'Company\\PersonPhoneRedirect.asp');
CopyAspTo('Imgs\\State.gif', ImagesDir+'Icons\\State.gif');

There are more techniques that we can use with the Component Manager.
  • CopyFile()
  • FileOpen()
  • QueryResults to File()
  • SearchAndReplaceInCustomFile()
  • SearchAndReplaceInDir()
  • SearchAndReplaceInFile()
These are documented within the Developer guide and there are examples of usage in the Advanced Customization Wizard.

I have to thank one of my colleagues in Australia who provided the core of this article at the suggestion of a North American colleague.