Search code examples
asp.netvbscriptasp-classiciis-7.5filesystemobject

How to enable FileSystemObject to detect Extension-less files


This is a standard text/html file without any extension (ie: c:\noextensionfile), that has the proper Mime Type in place to serve it as a text/html, that does work on the client-side as it should, however, when I use the FileSystemObject object on the server-side to manipulate the file (move, delete, etc.) all I get is a 'File Not Found.' error. I really don't know how to make this object detect an extension-less file. I have the proper permissions set, b/c it works with an extension, but otherwise, I get a not found error.

Example:

   oFs.FileExists("c:\noextensionfile") <-- Is always False
   oFs.DeleteFile("c:\noextensionfile") <-- Returns: File Not Found

The file does exist, just not to the object. How do I work-around this, I need to use extension-less file names. Thanks in advance.


Solution

  • Try this:

    Option Explicit
    
    Const FILE = "C:\bootmgr"
    
    Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
    WScript.Echo "File '" & FILE & "' exists? " & oFso.FileExists(FILE)
    

    When saved to a file (say noext.vbs) and run on my Windows 7 machine, I get:

    File 'C:\bootmgr' exists? True
    

    I'd think you'd get a similar result within your ASP Classic script.