アプリ版:「スタンプのみでお礼する」機能のリリースについて

環境
OS:WINDOWS 2000 PRO
ソフト:VisualBasic 6.0

指定したフォルダ配下の全てのhtmlファイルを読み込む機能を作成したいと考えています。

C:\AAA\BBB\CCC\sample1.html
C:\AAA\BBB\CCC\sample2.html
C:\AAA\BBB\CCC\DDD\sample3.html
C:\AAA\BBB\CCC\DDD\EEE\sample4.html
C:\AAA\XXX\YYY\ZZZ\sample5.html

以上のような構造になっていた場合に、ルートフォルダとして『C:\AAA』を指定し、その配下全てのhtmlファイルを読み込み、1ファイルずつ加工したいと考えています。
何階層にも渡るファイルを全て読み込む方法がわかりません。

よろしくお願い致します。

A 回答 (1件)

サブフォルダーのコレクションを作成して処理する方法になるでしょう



dim colDir as New Collection
dim colFile as New Collection
dim sParent as String, s as String
dim n as intgeer

sParent = "C:\AAA\"
s = dir( sParent, vbDirectory )
Do while s <> ""
 if s <> "." and s <> ".." then
  if GetAttr( sParent & s ) and vbDirectory then
   colDir.Add sParent & s
  else
    if left( s, 5) = ".html" then
     colFile.Add sParent & s
    end if
  end if
 end if
 s = dir
Loop
n = 1
do while n < colDir.Count + 1
 sParent = colDir(n) & "\"
 s = Dir( sParent, vbDirectory)
 do while s <> ""
  if s <> "." and s <> ".." then
   if GetAttr( sParent & s ) and vbDirectory then
    colDir.Add sParent & s
   else
    if left( s, 5) = ".html" then
     colFile.Add sParent & s
    end if
   end if
  end if
  s = dir
 loop
 n = n + 1
loop
といった具合で colFileにファイルパスを取得します
    • good
    • 0
この回答へのお礼

ありがとうございます。
助かりました。

お礼日時:2007/02/18 23:55

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!