GetDriveInfo() UDF Powered By .NET

This is an example that I used when demonstrating ColdFusion 8 .NET integration on the recent usergroup tour, and as requested, I am posting it publicly. GetDriveInfo() returns a query containing specifics about the hard drives on your server, it returns all drives unless an optional drive letter is passed to it. GetDriveInfo() uses the .NET System.IO.DriveInfo class (which was introduced in .NET 2, and thus this example requires .NET 2 or 3).
Here is the code:

And here is a simple test example:

All Drives

C: Drive

Free Space On C Drive

7 responses to “GetDriveInfo() UDF Powered By .NET”

  1. Ryan Guill Avatar
    Ryan Guill

    So I get that we can call .net code from cf, but can it work the other way around? Can someone in .net call some code that I write in CF through the same pipes?

  2. Damon Cooper Avatar
    Damon Cooper

    That’d be the .NET Gateway we didn’t have time for 🙂

  3. Ryan Guill Avatar
    Ryan Guill

    Ah, thanks Damon, that answers it.

  4. Ben Forta Avatar
    Ben Forta

    Ryan, which means that for now you’ll need to use Web Services.
    — Ben

  5. Rupesh Kumar Avatar
    Rupesh Kumar

    Why not let Microsoft build the capability to invoke CF component from .NET 😉
    On a serious note, I think the only way to do that currently is through webservices.

  6. Ryan Guill Avatar
    Ryan Guill

    Ha, I can see microsoft jumping at that chance… I can see the marketing now….
    If you invest in .net, you can do your heavy lifting in coldfusion!
    Seriously, thanks for your work on all of this guys, I can live with webservices for a little while longer, but here’s hoping for CF 9! 😉

  7. Jeremy Avatar

    Anyone know if there is a TCP/IP .Net assembly? I’m look to send a tcp/ip message to a server and receive a response from the server.

Leave a Reply