How do I Use FileSystemObject?

Discussion in 'ASP General' started by TC, Feb 4, 2008.

  1. TC

    TC Guest

    I'm trying to write some simple code using FSO, but I can't make it
    work. There are a many FSO tutorials on the web, but they all start
    with a line similar to:

    set fs=Server.CreateObject("Scripting.FileSystemObject")

    Yet that line simply doesn't work. I've tried it on my server and on
    my development PC, both of which are configured as web servers running
    ASP. I suspect that these computers simply aren't configured to
    support FSO, but nowhere can I find any hint of how to do that
    configuration. Can anyone help?

    -TC
    TC, Feb 4, 2008
    #1
    1. Advertising

  2. TC

    TC Guest

    On Feb 3, 8:52 pm, "McKirahan" <> wrote:
    > "TC" <> wrote in message
    >
    > news:...
    >
    > > I'm trying to write some simple code using FSO, but I can't make it
    > > work. There are a many FSO tutorials on the web, but they all start
    > > with a line similar to:

    >
    > > set fs=Server.CreateObject("Scripting.FileSystemObject")

    >
    > > Yet that line simply doesn't work. I've tried it on my server and on
    > > my development PC, both of which are configured as web servers running
    > > ASP. I suspect that these computers simply aren't configured to
    > > support FSO, but nowhere can I find any hint of how to do that
    > > configuration. Can anyone help?

    >
    > Try this:
    >
    > <% @Language="VBScript" %>
    > <%  Option Explicit
    >     Const cASP = "MapPath.asp"
    >     Dim strSMP
    >         strSMP = Server.MapPath(cASP)
    >     Response.Write "<li>" & strSMP
    >     Dim objFSO
    >     Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    >     Response.Write "<li>" & objFSO.GetFile(strSMP).DateCreated
    >     Set objFSO = Nothing
    > %>
    >
    > Call it via (or something like):http://localhost/MapPath.asp
    >
    > Here's the output I got:
    >
    > * C:\Inetpub\wwwroot\MapPath.asp
    > * 02/03/2008 10:44:19 PM
    >
    > What do you get?


    I get an "Invalid class string" error on line 8.
    TC, Feb 4, 2008
    #2
    1. Advertising

  3. TC

    TC Guest

    On Feb 4, 3:44 am, "McKirahan" <> wrote:
    > "TC" <> wrote in message
    >
    > news:...
    > On Feb 3, 8:52 pm, "McKirahan" <> wrote:
    >
    >
    >
    >
    >
    > > "TC" <> wrote in message

    >
    > >news:...

    >
    > > > I'm trying to write some simple code using FSO, but I can't make it
    > > > work. There are a many FSO tutorials on the web, but they all start
    > > > with a line similar to:

    >
    > > > set fs=Server.CreateObject("Scripting.FileSystemObject")

    >
    > > > Yet that line simply doesn't work. I've tried it on my server and on
    > > > my development PC, both of which are configured as web servers running
    > > > ASP. I suspect that these computers simply aren't configured to
    > > > support FSO, but nowhere can I find any hint of how to do that
    > > > configuration. Can anyone help?

    >
    > > Try this:

    >
    > > <% @Language="VBScript" %>
    > > <% Option Explicit
    > > Const cASP = "MapPath.asp"
    > > Dim strSMP
    > > strSMP = Server.MapPath(cASP)
    > > Response.Write "<li>" & strSMP
    > > Dim objFSO
    > > Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    > > Response.Write "<li>" & objFSO.GetFile(strSMP).DateCreated
    > > Set objFSO = Nothing
    > > %>

    >
    > > Call it via (or something like):http://localhost/MapPath.asp

    >
    > > Here's the output I got:

    >
    > > * C:\Inetpub\wwwroot\MapPath.asp
    > > * 02/03/2008 10:44:19 PM

    >
    > > What do you get?

    >
    > I get an "Invalid class string" error on line 8.
    >
    > What are you running?
    >
    > What's your:
    > a)    O/S; (e.g. Windows XP Pro)?
    > b)    IIS version; (e.g. IIS 5.1)?
    > c)    Web server's physical root path; (e.g. C:\Inetpub\wwwroot\)
    >
    > Does any ASP page work?
    >
    > For example, save the following as "MapPath.asp" (like before);
    > what does it return?
    >
    > <% @Language="VBScript" %>
    > <% Option Explicit
    > Const cASP = "MapPath.asp"
    > Response.Write "<li>" & Server.MapPath(cASP)
    > %>
    >
    > A Google of "IIS FSO" (without the quotes) found:
    >
    > [thelist] File System Object not working on IIS
    > URL:http://lists.evolt.org/archive/Week-of-Mon-20040726/162270.html
    >
    > Problems with FileSystemObject
    > URL:http://www.thescripts.com/forum/thread53833.html
    >
    > and others.- Hide quoted text -
    >
    > - Show quoted text -


    a) My operating system is Windows XP in one case, and Windows Server
    2003 in the other.
    b) I'm running IIS 5.1 and IIS 6.0.
    c) The web server's physical root path is C:\Inetpub\wwwroot\ on both
    computers.

    I've seen the pages blaming antivirus script blocking, but I don't
    think that's the problem in this case. My antivirus is NOD32. When I
    completely disable it, I see no change. Also, I believe that if script
    blocking was the problem, I would get an error when I try to use FSO,
    not when I try to initialize it. In other words, I would expect to
    hang on line 9, not receive an error on line 8, in the sample code
    above.

    In every test so far, I always fail on the line which includes
    Server.CreateObject("Scripting.FileSystemObject"). This leads me to
    ask, What are the prerequisites for using the FileSystemObject? Is it
    supposed to be automatically enabled on any computer running IIS?

    -TC
    TC, Feb 4, 2008
    #3
  4. TC

    TC Guest

    On Feb 4, 7:33 am, TC <> wrote:
    > On Feb 4, 3:44 am, "McKirahan" <> wrote:
    >
    >
    >
    >
    >
    > > "TC" <> wrote in message

    >
    > >news:...
    > > On Feb 3, 8:52 pm, "McKirahan" <> wrote:

    >
    > > > "TC" <> wrote in message

    >
    > > >news:....

    >
    > > > > I'm trying to write some simple code using FSO, but I can't make it
    > > > > work. There are a many FSO tutorials on the web, but they all start
    > > > > with a line similar to:

    >
    > > > > set fs=Server.CreateObject("Scripting.FileSystemObject")

    >
    > > > > Yet that line simply doesn't work. I've tried it on my server and on
    > > > > my development PC, both of which are configured as web servers running
    > > > > ASP. I suspect that these computers simply aren't configured to
    > > > > support FSO, but nowhere can I find any hint of how to do that
    > > > > configuration. Can anyone help?

    >
    > > > Try this:

    >
    > > > <% @Language="VBScript" %>
    > > > <% Option Explicit
    > > > Const cASP = "MapPath.asp"
    > > > Dim strSMP
    > > > strSMP = Server.MapPath(cASP)
    > > > Response.Write "<li>" & strSMP
    > > > Dim objFSO
    > > > Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    > > > Response.Write "<li>" & objFSO.GetFile(strSMP).DateCreated
    > > > Set objFSO = Nothing
    > > > %>

    >
    > > > Call it via (or something like):http://localhost/MapPath.asp

    >
    > > > Here's the output I got:

    >
    > > > * C:\Inetpub\wwwroot\MapPath.asp
    > > > * 02/03/2008 10:44:19 PM

    >
    > > > What do you get?

    >
    > > I get an "Invalid class string" error on line 8.

    >
    > > What are you running?

    >
    > > What's your:
    > > a)    O/S; (e.g. Windows XP Pro)?
    > > b)    IIS version; (e.g. IIS 5.1)?
    > > c)    Web server's physical root path; (e.g. C:\Inetpub\wwwroot\)

    >
    > > Does any ASP page work?

    >
    > > For example, save the following as "MapPath.asp" (like before);
    > > what does it return?

    >
    > > <% @Language="VBScript" %>
    > > <% Option Explicit
    > > Const cASP = "MapPath.asp"
    > > Response.Write "<li>" & Server.MapPath(cASP)
    > > %>

    >
    > > A Google of "IIS FSO" (without the quotes) found:

    >
    > > [thelist] File System Object not working on IIS
    > > URL:http://lists.evolt.org/archive/Week-of-Mon-20040726/162270.html

    >
    > > Problems with FileSystemObject
    > > URL:http://www.thescripts.com/forum/thread53833.html

    >
    > > and others.- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > a) My operating system is Windows XP in one case, and Windows Server
    > 2003 in the other.
    > b) I'm running IIS 5.1 and IIS 6.0.
    > c) The web server's physical root path is C:\Inetpub\wwwroot\ on both
    > computers.
    >
    > I've seen the pages blaming antivirus script blocking, but I don't
    > think that's the problem in this case. My antivirus is NOD32. When I
    > completely disable it, I see no change. Also, I believe that if script
    > blocking was the problem, I would get an error when I try to use FSO,
    > not when I try to initialize it. In other words, I would expect to
    > hang on line 9, not receive an error on line 8, in the sample code
    > above.
    >
    > In every test so far, I always fail on the line which includes
    > Server.CreateObject("Scripting.FileSystemObject"). This leads me to
    > ask, What are the prerequisites for using the FileSystemObject? Is it
    > supposed to be automatically enabled on any computer running IIS?
    >
    > -TC- Hide quoted text -
    >
    > - Show quoted text -


    I found the problem. Apparently, something changed my registry
    permissions. I went into the registry and corrected the permissions.
    Now FSO works. The bug is described in the following usenet articles:

    http://groups.google.com/group/microsoft.public.inetserver.iis/browse_thread/thread/aa4f80933182a5a2
    http://groups.google.com/group/micr...general/browse_thread/thread/98a8a12f6a2eb055

    -TC
    TC, Feb 4, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pedro Bautista
    Replies:
    0
    Views:
    529
    Pedro Bautista
    Aug 29, 2003
  2. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    FileSystemObject Question

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,701
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 22, 2004
  3. =?Utf-8?B?a2VybWl0?=

    Script w/ FileSystemObject, error creating object

    =?Utf-8?B?a2VybWl0?=, Apr 22, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    5,172
    =?Utf-8?B?a2VybWl0?=
    Apr 24, 2005
  4. Luis Esteban Valencia

    Using FileSystemObject in VB.NET

    Luis Esteban Valencia, Jul 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    35,531
    Juan T. Llibre
    Jul 14, 2005
  5. Juan Daniel Caicedo
    Replies:
    1
    Views:
    121
    Roland Hall
    Apr 5, 2005
Loading...

Share This Page