便曆某路徑下檔案夾,把所有MP3資料讀到資料庫

來源:互聯網
上載者:User
  1. <!--#include file="Sql_Conn.asp"--><!--#include file="Inc/Inc.asp"--><!--#include file="Inc/Config.asp"-->
  2. <%
  3. '本版本為OK版1.0  add by ym on 2008.11.17
  4. function GetExtendName(FileName) 
  5. dim ExtName 
  6. ExtName = LCase(FileName) 
  7. ExtName = right(ExtName,3) 
  8. ExtName = right(ExtName,3-Instr(ExtName,".")) 
  9. GetExtendName = ExtName 
  10. end function
  11. '便曆某路徑下檔案夾,把所有MP3資料讀到資料庫 
  12.     function bianli(path)
  13.         dim fso            'fso對象
  14.         dim objFolder      '檔案夾對象
  15.         dim objSubFolders '子檔案夾集合
  16.         dim objSubFolder   '子檔案夾對象
  17.         dim objFiles       '檔案集合
  18.         dim objFile        '檔案對象
  19.         set fso=server.CreateObject("scripting.filesystemobject")    
  20.         on error resume next
  21.         set objFolder=fso.GetFolder(path)'建立檔案夾對象
  22.         set objSubFolders=objFolder.Subfolders'建立的子檔案夾對象
  23.         for each objSubFolder in objSubFolders
  24.             'nowpath=path + "//" + objSubFolder.name
  25.             nowpath=path  + objSubFolder.name
  26.            ' Response.Write nowpath
  27.             set objFiles=objSubFolder.Files
  28.             for each objFile in objFiles
  29.               if GetExtendName(objFile.name)  = "mp3" then
  30.                               Response.Write "<br>"
  31.                 'Response.Write objFile.name
  32.                 
  33.                 dim lc_lj 
  34.                 lc_lj = nowpath + "/" +objFile.name
  35.                 lc_lj=Mid(lc_lj,4)         ' 由lc_lj的第4個字元讀起,讀取後面的所有字元。
  36.                 lc_lj=Replace(lc_lj,"/","/")
  37.                 'response.Write(lc_lj)
  38.                 
  39.                 dim lc_now
  40.                 lc_now = now()
  41.                 response.write lc_now
  42.                 
  43.                 dim sql_in
  44.                 'sql_in = "insert into ylmv_dj(djCat_Id,specialid,Dj_name,Hits,dj_url,path,dj_pic,dj_user,tjuser,dj_word,dj_desc,IsBest,istop,grade,DownHits,BoxHits,uHits,dHits,DayHits,WeekHits,MonthHits,error,passed,points,music,dj_date,lasthittime) values(11,0,'"+ objFile.name  +"',0,'"+ lc_lj +"',5,'rm','紫龍舞曲管理','admin','"+ objFile.name +"','☆☆★★★',1,1,1,0,0,0,0,0,0,0,0,0,0,0,'"+lc_now +"','"+lc_now+"')"
  45.                 sql_in1 = "insert into ylmv_dj(djCat_Id,specialid,Dj_name,Hits,dj_url,path,dj_pic,dj_user,tjuser,dj_word,dj_desc,IsBest,istop,grade,DownHits,BoxHits,uHits,dHits,DayHits,WeekHits,MonthHits,error,passed,points,music,deleted) values(11,0,'"+ objFile.name  +"',0,'"+ lc_lj +"',5,'rm','紫龍舞曲管理','admin','"+ objFile.name +"','☆☆★★★',1,1,1,0,0,0,0,0,0,0,0,0,0,0,0)"
  46.                 'Response.Write objFile.name
  47.                 'response.Write sql_in1
  48.                 conn.execute(sql_in1)
  49.                  Response.Write "<br>"
  50.                 response.Write("添加"+objFile.name+"!!!!!!")
  51.               end if
  52.             
  53.             next
  54.             Response.Write "<p>"
  55.             bianli(nowpath)    '調用遞迴
  56.         next
  57.         set objFolder=nothing
  58.         set objSubFolders=nothing
  59.         set fso=nothing
  60.     end function
  61. %>
  62. <%
  63.     bianli("F:/Music/") '調用bianli()函數,這裡是遍曆F:盤
  64. %>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.