FileLib.cfc
<cfcomponent>
<cfset this.fso = CreateObject("COM", "Scripting.FileSystemObject")>
function FolderSize(path)
{
Var folder = this.fso.Getfolder(path);
Return folder.Size;
}
etc...
</cfcomponent>
Store it in the application scope like so.
<cfset application.fileLib = createObject("component", "fileLib")>
Then call the methods just as you have been, just prefixing the calls
with 'application.fileLib.'.
#application.fileLib.FolderDateCreated(TheFolder)#
#application.fileLib.FolderDateLastAccessed(TheFolder)#
--
jon
mailto:[EMAIL PROTECTED]
Monday, September 29, 2003, 7:58:12 AM, you wrote:
B> Hi,
B> In my application I'm using the following CFC. This gets loaded everytime a user click on a file link to get the file information (date, size, etc.).
B> I've been told that I could speed things up substantially by just having one function do a
B> single COM connection and have the other functions just re-use the COM
B> connection (COM connections have to go through a login process each time
B> that obviously have a lot of overhead).
B> How can I do this?
B> Do I put the code in my application.cfm and then just reuse it? If so, how?
B> Below is the code I got off cflib.org
B> --CFSCRIPT--
B> /**
B> * Returns the date/time a folder (directory) was created. (Windows only)
B> *
B> * @param path Absolute or relative path to the specified folder.
B> * @return Returns a date/time object.
B> * @author Rob Brooks-Bilson ([EMAIL PROTECTED])
B> * @version 1.0, July 20, 2001
B> */
B> function FolderSize(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var folder = fso.Getfolder(path);
B> Return folder.Size;
B> }
B> function FolderDateLastAccessed(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var folder = fso.GetFolder(path);
B> Return folder.DateLastAccessed;
B> }
B> function FolderDateLastModified(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var folder = fso.GetFolder(path);
B> Return folder.DateLastModified;
B> }
B> function FolderDateCreated(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var folder = fso.GetFolder(path);
B> Return folder.DateCreated;
B> }
B> function FileDateCreated(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var theFile = fso.Getfile(path);
B> Return theFile.DateCreated;
B> }
B> function FileDateLastAccessed(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var theFile = fso.GetFile(path);
B> Return theFile.DateLastAccessed;
B> }
B> function FileDateLastModified(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var theFile = fso.GetFile(path);
B> Return theFile.DateLastModified;
B> }
B> function FileSize(path)
B> {
B> Var fso = CreateObject("COM", "Scripting.FileSystemObject");
B> Var theFile = fso.GetFile(path);
B> Return theFile.Size;
B> }
B> --/CFSCRIPT--
B> </head>
B> <cfset strFileName = ListLast(url.filename, "\")>
B> <cfset DirPath = Left(url.filename, Evaluate(Len(url.filename) - len(strFileName) - 1))>
B> <cfset TheFile = ListLast(url.filename)>
B> <cfset TheFolder = DirPath>
B> <body bgcolor="#617087" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">
B> <link rel="STYLESHEET" type="text/css" href="">
B> <br>
B> <p class="wdirlinks" align="center"><b>File Information</b>
B> <p class="wdirlinks">
B> <table width="100%" cellpadding="0" cellspacing="0" border="0">
B> <tr>
B> <td>
B> <table cellpadding="2" cellspacing="2" border="0">
B> <cfoutput>
B> <tr class="wdirlinks"><td width="70" align="right"><b>File:</b></td><td>#strFileName# created on #DateFormat(FileDateCreated(TheFile), 'mm/dd/yyyy')# at #TimeFormat
B> (FileDateCreated(TheFile), 'HH:MM:SS')#.</td></tr>
B> <tr class="wdirlinks"><td width="70"> </td><td>last accessed on #DateFormat(FileDateLastAccessed(TheFile), 'mm/dd/yyyy')# at #TimeFormat
B> (FileDateLastAccessed(TheFile), 'HH:MM:SS')#</td></tr>
B> <tr class="wdirlinks"><td width="70"> </td><td>last modified on #DateFormat(FileDateLastModified(TheFile), 'mm/dd/yyyy')# at #TimeFormat(FileDateLastModified
B> (TheFile), 'HH:MM:SS')#.</td></tr>
B> <tr class="wdirlinks"><td width="70" align="right"><b>Size:</b></td><td>#FileSize(TheFile)# bytes.</td></tr>
B> <tr class="wdirlinks"><td width="70" align="right"><b>Directory:</b></td><td>#TheFolder# created on #DateFormat(FolderDateCreated(TheFolder), 'mm/dd/yyyy')# at
B> #TimeFormat(FolderDateCreated(TheFolder), 'HH:MM:SS')#.</td></tr>
B> <tr class="wdirlinks"><td width="70"> </td><td>last accessed on #DateFormat(FolderDateLastAccessed(TheFolder), 'mm/dd/yyyy')# at #TimeFormat
B> (FolderDateLastAccessed(TheFolder), 'HH:MM:SS')#.</td></tr>
B> <tr class="wdirlinks"><td width="70"> </td><td>last modified on #DateFormat(FolderDateLastModified(TheFolder), 'mm/dd/yyyy')# at #TimeFormat
B> (FolderDateLastAccessed(TheFolder), 'HH:MM:SS')#.</td></tr>
B> <tr class="wdirlinks"><td width="70"> </td><td>size of directory (including all files/subdirectories) is #FolderSize(TheFolder)# bytes.</td></tr>
B> </cfoutput>
B> </table>
B> </td>
B> </tr>
B> </table>
B
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

