????? ??????? ????? ???? ????? ???????? 2005 Visual Basic ?? Visual Basic.net

?????? ????????? ?????? ?????????
???? ???????: 306666 - ??? ???????? ???? ????? ????? ??? ???????.
Microsoft Visual c + + 2005 ??????????? ??????? .NET c + + ???? ?? ??? ???????? ???? 307009.
Microsoft Visual C# 2005 ??????????? ??????? ????? C#.net ?? ??? ???????? ???? 303974.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????????? ???????? ????? ???? ????? ??????? ????? ???????? ???? ???? ????? ???. ??? ??? ????? ????? ??? ????? ????? ?? ??????? ???? ????? ????? ??????. ????? ?? ??? ?? ????????? ???????? ??? ???????. ?????? ?????? ????? ??? ???? ????? ????? ?? ????? ??? ???????.

?????? ??????? ???? IO ????? ????????. FileSystemObject ????? ??? ?????? ????? ???? ?????? (COM) ?????????. ???? ???? ???? ?? Microsoft.net ??? ?????? ????. ?????? ?? ????? ????? System.IO ????? ? FileSystemObject? ???? ????? ???????? ?????? ??? ??????? ? ???????.

???????

????? ???? ??????? ??????? ??????? ?????? ??? ???????? ??????? ?????? ????????? ???? ??????? ???? ???????:
  • Microsoft Visual Studio 2005 ?? Microsoft Visual Studio .NET
Microsoft ???? ????? ?????? ??????? ???? ??? ?? ???? ???? ???? ?? ????. ???? ?????? ???? ?? ????? ???? ??????? ?????? ???????? ??????? ?? ???????? ???? ????. ????? ??? ??????? ????? ??? ????? ??? ??? ??????? ???? ??? ??? ???????? ???? ??? ????????? ?????? ???????? ???????. ???? ?? ????? ?????? ????? ??? Microsoft ??? ??????? ????? ????? ?????? ?? ?????? ??? ??????? ?????? ????? ????? ?? ???? ??????? ?????? ??????? ?????.

??????? ??????

???? ?????? ????? ??????? ???????? ?? ????? ????? System.IO . ??? ????? ?? ??? ??????? ??? ??????? ????? ????? ??????? ?? ???????.
using System.IO;
				
???? ????? ????? System.IO ???? ?????? ?? ???????? ????? ?? ??????? ? ???????. ???? ????? ????? System.IO ?????? ???? ????? ????? ????? ??? ??? ?? ??? ???? ???? ?????? ???????? ????? ???????. ????? ??? ?????? ???????? ???????? ???? ????? ????????? ??? ?????? ??? ????? ????? ?? ??? ?????. ??? ???? ??????? ????? ??????? ???? ?????? ?????? ??? ??????? ??????? ????? ????.

?????? ???????? ???????? ??????? ????? GetDirectories ???????? ????? ?????? ?????? ???? ?????. ????? ??? ?????? ??? ????? ???? ?????? ??? ??????? ??????? ?????? C:\? ?? ????.
Dim directories() As String = Directory.GetDirectories("C:\")
				
????? ???? ?????? ???? ??? ????? GetFiles . ???? ?? ??????? ????? ????? ?? ??????? ???? ????? ??????? GetFiles ?????? ?????. ?????? ????? ????????? ???????? ??????? ???? ????? ???????? ???? ??????? ???? ????? ?? ?????? C:\ ??????? dll.
Dim files() As String = Directory.GetFiles("C:\", "*.dll")
				
??????? GetDirectories ?????? GetFiles ???? ?????? ?? ?? ?? ????? ??? ????? ???? ????? ?? ??????? ???? ????? ????? ?????. ??? ??????? ??????? ?????? ?????? ???????.
    Sub DirSearch(ByVal sDir As String)
        Dim d As String
        Dim f As String

        Try
            For Each d In Directory.GetDirectories(sDir)
                For Each f In Directory.GetFiles(d, txtFile.Text)
                    lstFilesFound.Items.Add(f)
                Next
                DirSearch(d)
            Next
        Catch excpt As System.Exception
            Debug.WriteLine(excpt.Message)
        End Try
    End Sub
				
????????? ???????? ??????? ?????? ????? ???? ????? ??? ?????? ???? ????? ????? ??? DirSearch. ???? ????? ??? ?? ??? ?????? ?????? ??????. ????? ????? ??????? ??????? GetDirectories ???????? ??????? ??????? ????? ????? ???? ?? ??????? ??? ??????? ????? ??. ??? ??????? GetDirectories ?????? ????? ????? ??????? ?/?? ?????? ?? ???????? ??? ?? ???? ????. ??? ???? ????? ?????? ??????? GetFiles ?????? ??????? ?? ??? ??????. ???? ??? ????? ???? ???? ??? ??????? ????? ?? ??? ??????? GetFiles . ???? ???? ????? ??? ????? ????? ???? ???? ?????? ??????? ???? ????? ??????? GetFiles . ??? ???? ??? ????? ????? ?????? ?????? ????? ??? ???? ???????. ??? ???? ???? ?????? ??????? DirSearch ??? ????? ?????? ???? ????. ???????? ??? ???????? ??????? ????? ????? ?? ???? ??????? ??????? ?????? ????? ??????.

????? ????????? ???????? ?????

  1. ??? ????? Microsoft Visual Basic 2005 ?? Microsoft Visual ???? ????? ????? Windows.net ???????. ???? ???????? ????? ???? ???? Form1 ??? ?????.
  2. ?? ??????? ??? ? ???? ???? "?????? ??????".
  3. ?? "?????? ??????"? ???? ????? ?????? Form1? ??? ?? ???? ??? ??? ????????? ????????.
  4. ?? ???? ????????? ???????? Form1 ?? ????? ???? ???? ????????? ???????? ????????.
  5. ?? ???? ???????? ???????? ??????? ?? ???? ????????? ???????? ? Form1 ???????.
    Imports System.IO
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call.
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
            Friend WithEvents cboDirectory As System.Windows.Forms.ComboBox
        Friend WithEvents txtFile As System.Windows.Forms.TextBox
        Friend WithEvents lstFilesFound As System.Windows.Forms.ListBox
        Friend WithEvents lblDirectory As System.Windows.Forms.Label
        Friend WithEvents lblFile As System.Windows.Forms.Label
        Friend WithEvents btnSearch As System.Windows.Forms.Button
            Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer.
        'You can use the Windows Form Designer to modify it; however, do not
        'use the code editor to modify it.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.btnSearch = New System.Windows.Forms.Button()
            Me.lblFile = New System.Windows.Forms.Label()
            Me.cboDirectory = New System.Windows.Forms.ComboBox()
            Me.txtFile = New System.Windows.Forms.TextBox()
            Me.lstFilesFound = New System.Windows.Forms.ListBox()
            Me.lblDirectory = New System.Windows.Forms.Label()
            Me.SuspendLayout()
            '
            'btnSearch
            '
            Me.btnSearch.Location = New System.Drawing.Point(608, 248)
            Me.btnSearch.Name = "btnSearch"
            Me.btnSearch.TabIndex = 0
            Me.btnSearch.Text = "Search"
            '
            'lblFile
            '
            Me.lblFile.Location = New System.Drawing.Point(8, 16)
            Me.lblFile.Name = "lblFile"
            Me.lblFile.Size = New System.Drawing.Size(144, 16)
            Me.lblFile.TabIndex = 5
            Me.lblFile.Text = "Search for files containing:"
            '
            'cboDirectory
            '
            Me.cboDirectory.DropDownWidth = 112
            Me.cboDirectory.Location = New System.Drawing.Point(8, 128)
            Me.cboDirectory.Name = "cboDirectory"
            Me.cboDirectory.Size = New System.Drawing.Size(120, 21)
            Me.cboDirectory.TabIndex = 2
            Me.cboDirectory.Text = "ComboBox1"
            '
            'txtFile
            '
            Me.txtFile.Location = New System.Drawing.Point(8, 40)
            Me.txtFile.Name = "txtFile"
            Me.txtFile.Size = New System.Drawing.Size(120, 20)
            Me.txtFile.TabIndex = 4
            Me.txtFile.Text = "*.dll"
            '
            'lstFilesFound
            '
            Me.lstFilesFound.Location = New System.Drawing.Point(152, 8)
            Me.lstFilesFound.Name = "lstFilesFound"
            Me.lstFilesFound.Size = New System.Drawing.Size(528, 225)
            Me.lstFilesFound.TabIndex = 1
            '
            'lblDirectory
            '
            Me.lblDirectory.Location = New System.Drawing.Point(8, 96)
            Me.lblDirectory.Name = "lblDirectory"
            Me.lblDirectory.Size = New System.Drawing.Size(120, 23)
            Me.lblDirectory.TabIndex = 3
            Me.lblDirectory.Text = "Look In:"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(688, 273)
            Me.Controls.AddRange(New System.Windows.Forms.Control() _
                {Me.lblFile, Me.txtFile, Me.lblDirectory, Me.cboDirectory, _
                Me.lstFilesFound, Me.btnSearch})
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
        Private Sub btnSearch_Click(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles btnSearch.Click
            lstFilesFound.Items.Clear()
            txtFile.Enabled = False
            cboDirectory.Enabled = False
            btnSearch.Text = "Searching..."
            Me.Cursor = Cursors.WaitCursor
            Application.DoEvents()
            DirSearch(cboDirectory.Text)
            btnSearch.Text = "Search"
            Me.Cursor = Cursors.Default
            txtFile.Enabled = True
            cboDirectory.Enabled = True
        End Sub
    
        Sub DirSearch(ByVal sDir As String)
            Dim d As String
            Dim f As String
    
            Try
                For Each d In Directory.GetDirectories(sDir)
                    For Each f In Directory.GetFiles(d, txtFile.Text)
                        lstFilesFound.Items.Add(f)
                    Next
                    DirSearch(d)
                Next
            Catch excpt As System.Exception
                Debug.WriteLine(excpt.Message)
            End Try
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles MyBase.Load
            Dim s As String
            cboDirectory.Items.Clear()
            For Each s In Directory.GetLogicalDrives()
                cboDirectory.Items.Add(s)
            Next
            cboDirectory.Text = "C:\"
        End Sub
    End Class
    					
    ?????? ??? ????? ????????? ???????? ?? Visual Basic 2005. ???? ???????? Visual Basic ????? ????? ??????? ??? ????? ????? Windows ???????. ??? ?? ????? ??????? Form1? ??????? ???? ???? ??????? Form1.vb ??????? ? Form1.Designer.vb. ???? ????????? ???????? ?? ??? Form1.vb. ???? ????? Windows ???? ???????? ???????? ?? ????? Form1.Designer.vb. ????? ???? ????? Windows ?????? ?????? ???????? ??????? ?????? ????? Form1 ??? ????? ??????. ???? ??? ?????? ?? ???? ??????? ??? ??? interspersed ?? ????????? ???????? ?????? ??.

    ????? ?? ????????? ??? ????????? ??? Visual Basic 2005 ??????? ?????? ???? ??? ???? ????? Microsoft (MSDN):
    .aspx http://msdn.microsoft.com/en-us/library/ms379584 (VS.80)
    ????? ?? ????????? ??? ???? ????? ? Windows Forms ????? ?? ?????? ???? MSDN ??? ??? ???????:
    http://msdn2.microsoft.com/en-us/library/ms171843.aspx
  6. ???? F5 ?????? ?????? ??????.

?????

????? ?? ????????? ???????? ???? ??? ??? ??????? ?????? ?????? ?? ????? ????? Microsoft:
302309????? ????? ??? ??? ???????? System.IO ?? 2005 Visual Basic ?? Visual Basic.net
????? ?? ????????? ?????? ??? Visual Basic .NET? ???? ????? Usenet ???????:
? visual Basic

???????

???? ???????: 306666 - ????? ??? ??????: 05/?????/1433 - ??????: 1.0
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbvs2005swept kbvs2005applies kbhowtomaster kbmt KB306666 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????306666

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com