How to enable FileSystemObject to detect Extension-less files

305 views Asked by At

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.

2

There are 2 answers

0
DavidRR On BEST ANSWER

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.

0
John On

I don't know if this will work but you could try to use OpenTextFile without extension (because here a file is expected) and then work from there:

http://msdn.microsoft.com/en-us/library/314cz14s(v=vs.84).aspx