三流君(TOP) /ASPで遊ぶ /記事一覧

ディレクトリ内のファイル一覧を表示する
FileSystemObjectの.GetFolder

FileSystemObjectの.GetFolderを使用して、ファイルの一覧を取得してみます
まずは、今のフォルダーが知りたいので(自分のHD上の位置)
Server.MapPath(".")とドットを指定すると
[d:\users\ken3_org\Cgi-bin\test]とフォルダー名が取得できます(IIS5.0はOK 6から..で親参照は厳しくなった?)

次は、.GetFolderを使用して、フォルダーオブジェクトを取得します
For Each OBJ In .Files でファイルのコレクションにアクセスします。
※下記の実行結果とソースを見てください。

読者から いただいたご指摘、
-- 2007/09/11 12:03:34 --
GetExtensionNameで拡張子を取得したほうが汎用性があがるよ。
またSet objDIR = Nothing
で明示的にメモリ解放するのがルール。解放しないならセッションに入れて毎回オブジェクトが存在するか確認するとよいですね。
--

d:\users\ken3_org\Cgi-bin\testのファイル一覧です
cnt.mdb 2008/07/19 20:21:51
cnt_asp.mdb 2008/07/19 20:14:07
cnt_backno.mdb 2008/07/19 20:25:29
cnt_etc.mdb 2008/07/19 20:31:02
cnt_rank.mdb 2008/07/19 19:45:26
db026.mdb 2008/07/18 23:20:43
db029.mdb 2008/07/19 19:54:47
db044.mdb 2008/07/19 19:26:00
db068.mdb 2008/07/18 16:28:52
db072.mdb 2003/11/19 17:13:38
db089.mdb 2003/12/22 0:05:49
db100.mdb 2004/10/31 18:22:06
db105.mdb 2005/04/11 4:05:00
dummy101.csv 2005/01/19 21:00:52
inc_mokuji.inc 2008/05/14 11:11:31
inc_mokuji_g.inc 2008/05/14 11:11:31
inc_sql.inc 2003/06/21 2:47:26
index.html 2008/05/27 14:50:49
info.inc 2008/04/14 15:09:20
info2.inc 2008/04/14 15:09:20
info_g.inc 2008/04/14 15:09:20
info_hed.inc 2008/04/14 15:09:20
info_MOKU.inc 2006/09/28 9:57:43
info_MOTO.inc 2006/09/28 9:57:43
komento.mdb 2007/01/19 10:44:44
out_src.inc 2008/06/19 15:09:50
out_src999.inc 2005/04/22 9:46:20
out_src_g.inc 2008/06/19 15:09:50
out_src_t.inc 2008/06/19 15:09:50
schema.ini 2005/01/23 12:09:34
test001-2.asp 2008/05/27 14:44:27
test001.asp 2008/05/27 14:44:27
test003-1.asp 2008/05/27 14:44:28
test003-2.asp 2008/05/27 14:44:28
test003-3.asp 2008/05/27 14:44:28
test003-4.asp 2008/05/27 14:44:28
test004-1.asp 2008/05/27 14:44:29
test004-1.html 2008/05/27 14:50:47
test005-1.asp 2008/05/27 14:44:29
test006-1.asp 2008/05/27 14:44:29
test006-2.asp 2008/05/27 14:44:29
test006.txt 2008/07/19 7:38:54
test007-1.asp 2008/05/27 14:44:21
test007-2.asp 2008/05/27 14:44:21
test007-3.asp 2008/05/27 14:44:21
test007.txt 2008/07/19 16:33:54
test008-1.asp 2008/05/27 14:44:22
test008-2.asp 2008/05/27 14:44:22
test008.txt 2008/07/19 2:30:43
test009-1.html 2008/05/27 14:50:47
test009-2.html 2008/05/27 14:50:47
test010-1.asp 2008/05/27 14:44:22
test010-2.asp 2008/05/27 14:44:22
test010-3.asp 2008/05/27 14:44:23
test011-1.asp 2008/05/27 14:44:23
test012-1.asp 2008/05/27 14:44:23
test012-2.asp 2008/05/27 14:44:23
test012.html 2008/05/27 14:50:47
test012.txt 2008/07/08 16:56:29
test013-1.asp 2008/05/27 14:44:24
test013-2.asp 2008/05/27 14:44:24
test013-3.asp 2008/05/27 14:44:24
test013.html 2008/05/27 14:50:48
test013.txt 2008/06/26 17:31:03
test014-1.asp 2008/05/27 14:44:24
test014-2.asp 2008/05/27 14:44:25
test015-1.asp 2008/05/27 14:44:25
test015-2.asp 2008/05/27 14:44:25
test016-1.asp 2008/05/27 14:44:25
test016.txt 2008/07/18 13:32:22
test017-1.asp 2008/05/27 14:44:26
test017-2.asp 2008/05/27 14:44:26
test017-3.asp 2008/05/27 14:44:26
test018-1.asp 2008/05/27 14:44:26
test018-2.asp 2008/05/27 14:44:27
test019-1.asp 2008/05/27 14:44:27
test020-1.asp 2008/05/27 14:44:42
test020-2.asp 2008/05/27 14:44:42
test021-1.asp 2008/05/27 14:44:43
test022-1.asp 2008/05/27 14:44:43
test022.html 2008/05/27 14:50:48
test022.txt 2008/07/16 17:38:42
test023-1.asp 2008/05/27 14:44:43
test024-1.asp 2008/05/27 14:44:43
test024-2.asp 2008/05/27 14:44:43
test025-1.asp 2008/05/27 14:44:44
test025.html 2008/05/27 14:50:48
test026-1.asp 2008/05/29 13:21:32
test027-1.asp 2008/05/27 14:44:44
test027-2.asp 2008/05/29 13:21:32
test028-1.asp 2008/05/27 14:44:45
test028-2.asp 2008/05/27 14:44:45
test029-1.asp 2008/05/27 14:44:45
test029-2.asp 2008/05/29 13:21:29
test029-3.asp 2008/05/29 13:27:45
test030-1.asp 2008/05/27 14:44:46
test031-1.asp 2008/05/27 14:44:46
test031-2.asp 2008/05/27 14:44:46
test032-1.asp 2008/05/29 13:21:31
test032-2.asp 2008/05/29 13:21:31
test033-1.asp 2008/05/29 13:21:30
test033-2.asp 2008/05/29 13:21:30
test034-1.asp 2008/05/27 14:44:39
test034-2.asp 2008/05/27 14:44:40
test035-1.asp 2008/05/27 14:44:40
test035-1.html 2008/05/27 14:50:48
test035-2.asp 2008/05/27 14:44:40
test035-2.html 2008/05/27 14:50:49
test036-1.asp 2008/05/27 14:44:40
test037-1.asp 2008/05/27 14:44:41
test038-1.asp 2008/05/27 14:44:41
test038-2.asp 2008/05/27 14:44:41
test038-3.asp 2008/05/27 14:44:41
test039-1.asp 2008/05/27 14:44:41
test039-2.asp 2008/05/27 14:44:42
test040-1.asp 2008/05/27 14:44:59
test040-2.asp 2008/05/27 14:44:59
test041-1.asp 2008/05/27 14:45:00
test042-1.asp 2008/05/27 14:45:00
test042-2.asp 2008/05/27 14:45:00
test042-3.asp 2008/05/27 14:45:00
test043-1.asp 2008/05/27 14:45:01
test044-1.asp 2008/05/27 14:45:01
test044-2.asp 2008/05/29 13:21:29
test045-1.asp 2008/05/27 14:45:02
test046-1.asp 2008/05/27 14:45:02
test046-2.asp 2008/05/27 14:45:02
test046-3.asp 2008/05/27 14:45:02
test047-1.asp 2008/05/29 13:21:31
test047-2.asp 2008/05/29 13:19:34
test048-1.asp 2008/05/27 14:45:03
test048-2.asp 2008/05/27 14:45:03
test048-3.asp 2008/05/27 14:45:03
test049-1.html 2008/05/27 14:50:49
test052-1.asp 2008/05/27 14:45:03
test052-2.asp 2008/05/27 14:45:04
test053-1.asp 2008/05/27 14:45:04
test053.xls 2006/04/26 19:39:38
test054-1.asp 2008/05/27 14:45:04
test055-1.asp 2008/05/27 14:45:04
test056-1.asp 2008/05/29 13:21:30
test056.xls 2008/07/19 1:39:29
test057-1.asp 2008/05/29 13:21:30
test057.xls 2008/07/19 16:52:36
test058-1.asp 2008/05/27 14:45:05
test058-2.asp 2008/05/27 14:45:05
test059-1.asp 2008/05/27 14:45:05
test061-1.asp 2008/05/27 14:45:20
test062-1.asp 2008/05/27 14:45:20
test062-2.asp 2008/05/27 14:45:20
test064-1.asp 2008/05/27 14:45:21
test065-1.asp 2008/05/27 14:45:21
test065-2.asp 2008/05/27 14:45:21
test065-3.asp 2008/05/27 14:45:21
test066-1.asp 2008/05/27 14:45:22
test066-2.asp 2008/05/27 14:45:22
test067-1.asp 2008/05/27 14:45:22
test068-1.asp 2008/05/29 13:21:30
test068-2.asp 2008/05/29 13:21:29
test068.html 2008/05/27 14:50:49
test069-1.asp 2008/05/27 14:45:23
test070-1.asp 2008/05/27 14:45:23
test071-1.asp 2008/05/29 13:21:32
test072-1.asp 2008/05/27 14:45:24
test072-2.asp 2008/05/27 14:45:24
test072-3.asp 2008/05/27 14:45:24
test072-4.asp 2008/05/27 14:45:24
test073-1.asp 2008/05/27 14:45:24
test073-2.asp 2008/05/27 14:45:25
test073-3.asp 2008/05/27 14:45:16
test074-1.asp 2008/05/27 14:45:17
test074-2.asp 2008/05/27 14:45:17
test075-1.asp 2008/05/27 14:45:17
test075-2.asp 2008/05/27 14:45:17
test075-3.asp 2008/05/27 14:45:17
test076-1.asp 2008/05/27 14:45:18
test076-2.asp 2008/05/27 14:45:18
test076-3.asp 2008/05/27 14:45:18
test077-1.asp 2008/05/27 14:45:18
test077-2.asp 2008/05/27 14:45:19
test077-3.asp 2008/05/27 14:45:19
test078-1.asp 2008/05/27 14:45:19
test078-2.asp 2008/05/27 14:45:19
test079-1.asp 2008/05/27 14:45:20
test080-1.asp 2008/05/27 14:45:42
test080-2.asp 2008/05/27 14:45:42
test080-3.asp 2008/05/27 14:45:43
test080.csv 2004/04/17 1:14:23
test081-1.asp 2008/05/27 14:45:43
test081-2.asp 2008/05/27 14:45:43
test082-1.asp 2008/05/27 14:45:43
test083-1.asp 2008/05/27 14:45:44
test083-2.asp 2008/05/27 14:45:44
test083-3.asp 2008/05/27 14:45:44
test084-1.asp 2008/05/27 14:45:44
test084.xls 2006/04/26 19:39:42
test085-1.asp 2008/05/27 14:45:44
test086-1.asp 2008/05/27 14:45:45
test086-2.asp 2008/05/27 14:45:45
test087-1.asp 2008/05/27 14:45:45
test088-1.asp 2008/05/27 14:45:45
test088-2.asp 2008/05/27 14:45:46
test089-1.asp 2008/05/27 14:45:46
test089-2.asp 2008/05/27 14:45:46
test090-1.asp 2008/05/27 14:45:46
test090-2.asp 2008/05/27 14:45:47
test090.csv 2004/04/17 1:14:27
test091-1.asp 2008/05/29 13:21:31
test091.csv 2008/07/19 8:18:31
test092-1.asp 2008/05/27 14:45:47
test092-2.asp 2008/05/27 14:45:47
test093-1.asp 2008/05/27 14:45:48
test093-2.asp 2008/05/27 14:45:39
test093-3.asp 2008/05/27 14:45:39
test093-4.asp 2008/05/27 14:45:39
test093-5.asp 2008/05/31 9:43:08
test094-1.asp 2008/05/27 14:45:40
test094-2.asp 2008/05/27 14:45:40
test094-3.asp 2008/05/27 14:45:40
test095-1.asp 2008/05/27 14:45:40
test096-1.asp 2008/05/27 14:45:41
test097-1.asp 2008/05/27 14:45:41
test097-2.asp 2008/05/27 14:45:41
test097-3.asp 2008/05/27 14:45:41
test098-1.asp 2008/05/27 14:45:42
test098-2.asp 2008/05/27 14:45:42
test099-1.asp 2008/05/27 14:45:42
test100-1.asp 2008/05/27 14:46:04
test100-2.asp 2008/05/27 14:46:01
test100-3.asp 2008/05/27 14:46:01
test100-4.asp 2008/05/27 14:46:01
test100-5.asp 2008/05/27 14:46:01
test101-1.asp 2008/05/27 14:46:01
test101-2.asp 2008/05/27 14:46:02
test101-3.asp 2008/05/27 14:46:02
test101.csv 2005/01/19 19:04:51
test102-1.asp 2008/05/27 14:46:02
test102.csv 2005/01/23 12:09:35
test103-1.asp 2008/05/27 14:46:02
test103-2.asp 2008/05/29 13:21:31
test103.xls 2008/07/17 16:36:39
test104-1.asp 2008/05/27 14:46:03
test104-2.asp 2008/05/27 14:46:03
test105-1.asp 2008/05/27 14:46:03
test105-2.asp 2008/05/27 14:46:03
test106-1.asp 2008/05/27 14:46:03
test107-1.asp 2008/05/27 14:46:04
test108-1.asp 2008/05/27 14:46:04
test108.txt 2008/02/22 23:37:35


コーヒーブレイク たまには寄り道、休憩も(↓広告です):
広告:[7月の商品紹介] ← 基本?の当月を紹介
[9月の商品紹介] ← 少し先に発売の商品で予約を狙う
[4月の人気商品] ← 三ヶ月前に発売した人気の商品

.GetFolderを使用したサンプル(ソースの紹介)

詳細解説は[http:/asp/backno/asp067.html]を見てください
下記、/cgi-bin/test/test067-1.aspのソース(中身)です

.GetFolder を 使った ソースコードを紹介する

表示色の説明:ASP VBScriptは <% 〜 %>
キーワードは.GetFolder です。 <%@LANGUAGE=VBScript%> <html> <head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-sjis"> <title>ディレクトリ内のファイル一覧を表示する FileSystemObjectの.GetFolder</title> </head> <body> <h2>ディレクトリ内のファイル一覧を表示する<br>FileSystemObjectの.GetFolder</h2> <b>FileSystemObjectの.GetFolder</b>を使用して、ファイルの一覧を取得してみます<br> まずは、今のフォルダーが知りたいので(自分のHD上の位置)<br> Server.MapPath(".")とドットを指定すると<br> [<%=Server.MapPath(".")%>]とフォルダー名が取得できます(IIS5.0はOK 6から..で親参照は厳しくなった?)<br> <br> 次は、.GetFolderを使用して、フォルダーオブジェクトを取得します<br> For Each OBJ In .Files でファイルのコレクションにアクセスします。<br> ※下記の実行結果とソースを見てください。<br> <br>読者から いただいたご指摘、<br> -- 2007/09/11 12:03:34 --<br> GetExtensionNameで拡張子を取得したほうが汎用性があがるよ。<br> またSet objDIR = Nothing<br> で明示的にメモリ解放するのがルール。解放しないならセッションに入れて毎回オブジェクトが存在するか確認するとよいですね。<br> --<br> <hr> <% '*1 FileSystemObjectを生成します、、って英文、そのままジャン。 Set objFS = Server.CreateObject("Scripting.FileSystemObject") '*2 フォルダーの名称を取り出す strFDIRNAME = Server.MapPath(".") 'フォルダー名取得 Response.Write strFDIRNAME & "のファイル一覧です<br>" & vbCRLF '*3 .GetFolderで、フォルダーオブジェクトを取得します Set objDIR = objFS.GetFolder(strFDIRNAME) '*4 .Filesコレクションにアクセスする For Each objFILE In objDIR.Files strFNAME = objFILE.Name '取り出したobjFILEの.Nameを取得 If Right(strFNAME, 4) = ".asp" Then '.ASPならリンクを作る Response.Write "<a href='" & strFNAME & "'>" Response.Write strFNAME & "</a>" & vbTab Else Response.Write strFNAME & vbTab End If 'おまけで更新日の表示 Response.Write objFILE.DateLastModified & "<br>" & vbCRLF Next %> <hr> </body> </html>

最近発売の雑誌を紹介する

科学や技術の雑誌です。
  1. 電気店 2008年 08月号
  2. 機械化農業 2008年 08月号
  3. 工業材料 2008年 08月号
  4. 電気と工事 2008年 08月号
  5. 固体物理 2008年 06月号
  6. 電設技術 2008年 07月号
  7. 型技術 2008年 08月号
  8. 電気評論 2008年 07月号
  9. 標準化と品質管理 2008年 08月号

データベースの書籍を紹介します

  1. [4798107980]- オラクルマスター教科書 Bronze Oracle Database 10g(DBA10g)編 (オラクルマスター教科書)
  2. [4797323132]- SEのためのOracleチューニングハンドブック
  3. [4756148360]- FileMaker データベース開発テクニック
  4. [4891005114]- ひと目でわかるMicrosoft SQL Server 2005 (マイクロソフト公式解説書)
  5. [4883374610]- Access VBAプログラミング開発工房 データベース構築実践編
  6. [479810566X]- グラス片手にデータベース設計~販売管理システム編 (DBMagazine SELECTION)

※Ken3への連絡先 → [メール@アドレス]です。気軽に問い合わせてください

Googleで関連項目を検索する

LANGUAGE=VBScript + [キーワード:.GetFolder] Sub|Function プログラム|プログラミング
↓で検索するとプログラムの例 Sub/Function でまとまったHP

Google

あれ?私のページが検索に載ってない(笑)一度お試しを(私のページに、また戻ってきてね(爆))

三流解説とリンクページを紹介

ASP系の解説を項目ごとにまとめてみました

[ASP Form等を使用したデータのやり取り]
[ASP その他処理サンプル]
[ASP テキストファイル処理]
[ASP VBScript関数関係の説明]
[ASP ADOでMdbファイルを使う]
[ASP ADOでExcelと接続してみた]

その他:blogや広告↓
[日記的なblog]← あまり更新してないけど・・・
[三流なプログラムコード]← 恥ずかしいのであまり載せてないけど・・・
[通販商品の足跡を紹介] ←通販商品などを紹介してます


現在時刻は、2008/07/19 20:32:00です。
[Topへ戻る] −−>[ASP系へ戻る] −−>[バックナンバーを見る]