<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      用VFP管理頁面文件

      [摘要]作者:何詠明、尹有仁 隨著計算機技術的發展,Internet已經滲透到我們生活的各個方面中,如何管理和維護一個網站中的網頁文件,對于網站來說至關重要。筆者利用VFP的管理思想,將網站的一個目錄樹及...
      作者:何詠明、尹有仁

      隨著計算機技術的發展,Internet已經滲透到我們生活的各個方面中,如何管理和維護一個網站中的網頁文件,對于網站來說至關重要。

      筆者利用VFP的管理思想,將網站的一個目錄樹及其下面的所有網頁文本保存到庫中從而達到維護網頁文件的功能,這樣當某一個用戶無意中刪除了網頁文件時可以借助于存放在庫中的文件加以恢復。

      功能介紹
      利用VFP創建一個表單,在該表單中安排四個命令按鈕,如圖所示。選擇站點目錄是直接調用VFP的函數選定一個目錄,并將選定的目錄保存到一個歷史表history_tab(字段:dir_name);保存網頁文件則通過編寫一個遞歸調用的遍歷目錄樹的函數thisform.search(cur_directory)來遍歷選定的一個目錄,將該目錄中所需要的網頁文件獲取到一個表data_asp;恢復網頁文件則是直接從表data_asp中恢復所有的網頁文件。



      保存選定目錄中的網頁文件需要借助于遞歸調用的思想方法來遍歷一個目錄樹,這可以使用數據結構中所謂“深度優先搜索”的算法來完成,表單中的方法程序search(current_dir)就是完成該功能。

      實現代碼
      表單中的方法程序及命令按鈕代碼如下:
      添加的表單方法程序:thisform.search,參數current_dir
      parametercurrent_dir
      locali,cur_dir,tempdir,file1(1,1),extens,ok,file2
      chdir(current_dir)
      =adir(file1,".","AD")&&&&將該目錄下的所有文件保存到數組file1中
      cur_dir=curdir()&&&&保存當前目錄
      fori=1toalen(file1,1)
      若遇到一個子目錄時則進行遞歸調用
      ifalltrim(file1(i,1))!="."andalltrim(file1(i,1))!=".."and("D"$file1(i,5))
      ifright(rtrim(cur_dir),1)="\"
      tempdir=cur_dir+file1(i,1)
      else
      tempdir=cur_dir+"\"+file1(i,1)
      endif
      thisform.search(tempdir)
      else


      檢測是否是網頁擴展名
      chdir(cur_dir)&&&&回退到父目錄
      ok=.f.&&&&一個文件目錄是否為網頁文件
      ifat(".",fullpath(file1(i,1)))<>0
      extens=right(fullpath(file1(i,1)),len(fullpath(file1(i,1)))-at(".",fullpath(file1(i,1))))
      docase
      caselower(extens)="asp"
      ok=.t.
      caselower(extens)="htm"
      ok=.t.
      caselower(extens)="html"
      ok=.t.
      caselower(extens)="php"
      ok=.t.
      caselower(extens)="htx"
      ok=1
      caselower(extens)=”js”
      ok=.t.
      caselower(extens)="idc"
      ok=.t.
      caselower(extens)="idx"
      ok=.t.
      endc
      ifok=.t.
      &&&&是網頁文件則插入到表data_asp中
      file2=fullpath(file1(i,1))
      insertintodata_aspvalues(file2,"",thisform.cur_directory)
      appememocontentfrom(file2)
      endif
      endif
      endif
      next


      選擇站點目錄
      thisform.cur_directory=getdir()
      selecthistory_tab
      locateallfordir_name=thisform.cur_directory
      iffound()
      insertintohistory_tabvalues(thisform.cur_directory)
      else
      selectdata_asp
      deleallfordir_name=thisform.cur_directory
      endif


      保存網頁文件
      localchoice,defaultdir
      ifalltrim(thisform.cur_directory)==""
      choice=messagebox
      ("你應該選擇一個站點目錄",0)
      else
      defaultdir=curdir()
      chdir(thisform.cur_directory)
      =thisform.search(thisform.cur_directory)
      chdir(defaultdir)
      endif



      恢復網頁文件
      selectdata_asp
      setdeleteon
      gotop
      scan
      copymemocontentto(filename)
      endscan
      return
      *退出
      selectdata_asp
      pack
      selecthistory_tab
      pack
      closeall
      releasethisform


      這里,我們僅實現了文本文件的保存和恢復,如果將通用型字段加入到表中,就可以實現對于圖形文件的保存和恢復,那么該程序就更加完善了。


      日韩精品一区二区三区高清