登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

樱之花

叶散的时候,你明白欢聚;花谢的时候,你明白青春.

 
 
 

日志

 
 
关于我

分类中“我的实验室”是我在日常工作中的一些知识总结,有些写的比较匆忙,可能大家在阅读时会产生困扰,后期有时间我会重新整理编辑,谢谢大家的到访,您们的支持是我前进的动力!

遍历PDA的资源管理器中的所有文件和文件夹  

2008-03-03 08:10:52|  分类: Windows Mobile |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Imports System.IO
Imports System
Public Class Form1
    Dim StrFiles As String = ""
    Dim StrDirs As String = ""
    Dim SaveFilePath As String = "\Program Files\PdaFiles\PdaFiles.txt"
    Dim sw As StreamWriter
    Dim i As Integer = 0
    Private Sub BtnShowDirs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnShowDirs.Click
        BtnShowDirs.Enabled = False
        Dim path As String = TxtDirPath.Text.Trim
        If File.Exists(SaveFilePath) Then
            File.Delete(SaveFilePath)
        End If
        sw = File.CreateText(SaveFilePath)
        Call GetDirFiles(path, 0)
        sw.Close()
        BtnShowDirs.Enabled = True
        'MessageBox.Show("检索成功!")
        Me.Close()
    End Sub

    Private Sub GetDirFiles(ByVal sDirect As String, ByVal sCurGrade As Integer)
        sCurGrade = sCurGrade + 1
        Dim dir As DirectoryInfo
        Dim dirinfo As New DirectoryInfo(sDirect)
        Dim fileinfos As FileInfo
        Dim AllFileInfos() As FileInfo
        Dim str As String = ""
        Dim j As Integer = 0

        '获取文件
        '写文件
        For j = 0 To sCurGrade
            str = str & "    "
        Next
        sw.WriteLine(str & sDirect)
        sw.Flush()
        AllFileInfos = dirinfo.GetFiles
        For Each fileinfos In AllFileInfos
            '写文件
            sw.WriteLine(str & "    |-" & fileinfos.Name & "(" & CInt(fileinfos.Length / 1024) & "K)")
            sw.Flush()
        Next

        If AllFileInfos.Length = 0 Then
            sw.WriteLine(str & "    |-None")
            sw.Flush()
        End If

        For Each dir In dirinfo.GetDirectories
            Call GetDirFiles(dir.FullName, sCurGrade)
        Next
    End Sub

    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Me.Close()
    End Sub

    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        Me.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Cursor.Current = Cursors.Default
        Dim path As String = "\"
        If File.Exists(SaveFilePath) Then
            File.Delete(SaveFilePath)
        End If
        sw = File.CreateText(SaveFilePath)
        Call GetDirFiles(path, -2)
        sw.Close()
        Me.Close()
    End Sub
End Class

  评论这张
 
阅读(937)| 评论(1)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018