" class="title" title="home again woohoo">Home ?> pages bg right



ASP , Reading directories

Well… I almost don’t work with web apps written in ASP.
However, every now and then a client asks for a site in this language.

And every single time, i have to look at my “cheat sheet” to remember some simple stuff.
So… as sometimes my files get messy, and hard to find, i’ll be posting some of those “cheats” here.

(This, was practically copied from here : http://sestud.uv.es/manual.esp/asp/asp16.htm )

Server.CreateObject Method


Server.CreateObject(“Scripting.FileSystemObject”)

Using this object, we will have a way to look (and change) to the structure of files/folders on a given system. First, you need to create a FileSystem object, and then, the File or Folder object (i think you can guess which one is for files , or folders)

<%
  Set FS = Server.CreateObject("Scripting.FileSystemObject")
  Set File = FS.GetFile("C:\ASP\text.txt")
  Set Folder = FS.GetFolder("C:\ASP")
%>

* FS is a FileSystem object, which will allow us to access the file system on the server.
* File is a File object, which will allow us to access the properties of a text fiel, called text.txt (under c:\ASP\)
* Folder is a Folder object (duh), and will allow us to access properties of the c:\ASP folder.

Now… lets take a look at the properties, that can be “read only” (R) or “read/write” (RW). I’ll use Object as a wildcard for both, File and Folder.

  • Objeto.Attributes [=new] Set a new, or show attributes of an object. Values are as follow (you can use either the Name, or the value) :
    • Normal = 0 Normal file. No attributes changed.
    • ReadOnly = 1 Read Only File. RW
    • Hidden = 2 Hidden File. RW
    • System = 4 System File. RW
    • Volume = 8 Volume Label of Disk. R
    • Directory = 16 Folder. R
    • Archive = 32 File has been modified since last backup. RW
    • Alias = 64 Link to another file. R
    • compressed = 128 Compressed file. R
  • Objeto.DateCreated Returns the full date when the object was created. R
  • Objeto.DateLastAccessed Returns the full date when the object was last accessed. R
  • Objeto.DateLastModified Returns the full date when the object was last modified. R
  • Objeto.Drive Returns the drive letter where the object resides. R
  • Objeto.Name [= newname] Returns the name, or sets a new name. RW
  • Objeto.ParentFolder Return the parent folder of the object. R
  • Objeto.Path Returns the full path of the object R
  • Objeto.ShortName Returns the short name (8.3), also called DOS Name. R
  • Objeto.ShortPath Returns the short path (8.3), also called DOS Path. R
  • Objeto.Size With files, returns the size of the File. With folders, return the size in bytes of all files/folders within it. R
  • Objeto.Type Returns a descriptive text of the type of file. I.e. a gif file will return “GIF Image”. R
  • Directorio.Files Returns a file collection, containing all the Files contained in the Folder. This includes hidden and system files. R
  • Directorio.SubFolders Return a folder collection, containing all subfolders, including hidden and system folders.R
  • Directorio.IsRootFolder Returns True if the folder is the root folder. False if it isn’t.

And now, the methods:

  • Objeto.Copy dest[, overwrite] Copies a file or folder to “dest”. The optional “overwrite” flag (True or False), specifies if “dest” will be overwritten if it exists. “dest” cannot contain wildcards.
  • Objeto.Delete option Deletes a file or a folder. If “option” is True, files with readonly attribute will be deleted; False (default) won’t.
  • Objeto.Move dest Moves a file or folder, to “dest”. “dest” cannot have wildcards.

In every case, every object must be closed in the reverse order they were created.

<%
  File.Close
  Set File = Nothing
  Folder.Close
  Set Folder = Nothing
  FS.Close
  Set FS = Nothing
%>

To finish, a full example of a directory listing :

<%
    set fs = CreateObject("Scripting.FileSystemObject")
    path = Server.MapPath("/")
    set folder = fs.GetFolder(path)

    For each file in folder.Files
        Response.write "Filename : " & File.Name & " <br>"
    Next
%>


How to kill your laptop….

* pictures taken from notebookreview forums. this post

Well…
It is known, that when using laptops, updating the BIOS has to be one of the most careful things to do.

When you say careful, you mainly mean : DONT DO IT UNDER WINDOWS.

Most of these warning are from old days. I figured… lot of time has passed, and they wont apply. (I use linux 64bit all the time… but that day, i was running windows (playing Red Alert 3), and just saw the right moment to try Asus WinFlash)

Big mistake.

Flashed correctly… Verified Ok, then said just reboot. Rebooted, and black screen. No signs of life other than the fan running steadly.
Damn, i said.

* This was my rescue kit setup :-)

I figured, as my laptop is an Asus G1 with Ami Bios, i could try and access the bootblock to restore the bios image.
Wrong. Tried USB Floppy drive, cdrom containing only the file (amiboot.rom), turned on the laptop pressing esc, alt f2, control esc, control pgup, etc, etc.
Nothing.
It looked like something was interfering the bootblock code. (Im not certain on this, but it seems the media playback feature of the laptop, avoided the bootblock code from ever executing).

So… Go to the Asus website (and forums) to ask for some pointers.
Tech support didn’t have a clue. They said i’ll have to take my laptop to service. (good one). or try different combo keys (all of them tried before).
Service said (without even looking at it) bad mainboard, replace and give us lots of money. (yeah, right).
I tried again support, and ask them to pointers on how to open the system to access the bios chipset. They said “we can’t give you that info, because is private”.

Turns out the laptop is pretty easy to crack open.

* A little overview in the process. Unfortunately, i forgot to take pictures of the non-socketed chip :-(

I did it. Cracked it open, found the flash chip (SST 49LF004B rev CA), desoldered using a hot air station, soldered a nice PLCC32 socket, reprogrammed the flash chip with latest bios (yes, bin file provided by asus is a straight image of the chip), put it all together. IT’S ALIVE!!!

* Thats how the socketed bios looks now. And, the process of programming.

So.. now that i have a pretty socket and the ability to get the flash chip when i want, i’ll be trying some bios mods. (i.e. I want to be able to access more than the 3GBs the bios recognize. This is because the memory chipset only beign able to address 4GB, and bios not providing some remap functions.. but that’s another story).

Sounds easy right ? Well… it isn’t so difficult. Just be patient and careful. I already broke a pin in the LCD connector… I’m lucky it isn’t used.

Page 3 of 5«12345»