2008-03-03 08:10:52| 分类: Windows Mobile | 标签: |举报 |字号大中小 订阅
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
评论