求助,vbnet,遍历电脑所有文件,将*.EXE文件路径添加到listbox中 vb.net怎么把一个文件夹的所有文件都添加到listbox...
C# \u904d\u5386\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u5b50\u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\uff0c\u5982\u4f55\u5f97\u5230\u6587\u4ef6\u540d\uff1f\u8f93\u5165\u67d0\u6587\u4ef6\u5939\u8def\u5f84\uff0c\u904d\u5386\u8be5\u6587\u4ef6\u5939\u53ca\u5176\u5b50\u6587\u4ef6\u5939\uff08\u5305\u62ec\u5b50\u6587\u4ef6\u5939\u7684\u5b50\u6587\u4ef6\u5939\u7b49\uff09\uff0c\u83b7\u53d6\u5176\u4e2d\u6240\u6709\u6587\u4ef6\u7684\u51fd\u6570\uff1a
/// /// \u67e5\u627e\u6307\u5b9a\u6587\u4ef6\u5939\u4e0b\u6307\u5b9a\u540e\u7f00\u540d\u7684\u6587\u4ef6/// /// \u6587\u4ef6\u5939/// \u540e\u7f00\u540d/// \u6587\u4ef6\u8def\u5f84public void GetFiles(DirectoryInfo directory, string pattern, ref List fileList){if (directory.Exists || pattern.Trim() != string.Empty){try{foreach (FileInfo info in directory.GetFiles(pattern)){fileList.Add(info.FullName.ToString());}}catch (System.Exception ex){Console.WriteLine(ex.ToString());}foreach (DirectoryInfo info in directory.GetDirectories())//\u83b7\u53d6\u6587\u4ef6\u5939\u4e0b\u7684\u5b50\u6587\u4ef6\u5939{GetFiles(info, pattern, ref fileList);//\u9012\u5f52\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u83b7\u53d6\u5b50\u6587\u4ef6\u5939\u4e0b\u7684\u6587\u4ef6}}}
\u4f7f\u7528\u5b9e\u4f8b\uff1a
List FindResult = new List();
GetFiles(new DirectoryInfo(@"C:\","*.*", ref FindResult); //\u83b7\u53d6C\u76d8\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u8def\u5f84GetFiles(new DirectoryInfo(@"\\192.168.1.107\Save"), "*.*", ref FindResult);//\u83b7\u53d6\u5c40\u57df\u7f51\u4e0a\u5171\u4eab\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6
\u4f7f\u7528FolderBrowserDialog\u63a7\u4ef6
If FolderBrowserDialog1.ShowDialog() DialogResult.Cancel Then
TextBox6.Text = FolderBrowserDialog1.SelectedPath
TextBox6.SelectionStart = TextBox6.Text.Length
Dim FileNames() As String = Directory.GetFiles(TextBox6.Text)
For i As Integer = 0 To FileNames.Length - 1
ListBox1.Items.Add(Path.GetFileName(FileNames(i)))
Next
End If
Imports System.Text.RegularExpressions
Public Class Form1
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Integer, ByVal lpBuffer As String) As Integer
Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer
Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByVal lpVolumeSerialNumber As Integer, ByVal lpMaximumComponentLength As Integer, ByVal lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim My_path As String = Space(200)
GetLogicalDriveStrings(200, My_path)
Dim g_path() As String = (From mt As Match In Regex.Matches(My_path, "\D:\\") Select mt.Value).ToArray
For i = 0 To g_path.GetUpperBound(0)
If GetDriveType(g_path(i)) = 3 Then
Dim My_name As String = Space(200)
GetVolumeInformation(g_path(i), My_name, 200, 0, 0, 0, vbNullString, 0)
My_name = Regex.Replace(My_name, "[^\w]", "")
If My_name <> "RamDisk" Then
Dim My_file() As String = System.IO.Directory.GetFiles(g_path(i), "*.exe", IO.SearchOption.AllDirectories)
For Each bs As String In My_file
If FileLen(bs) > 5000 * 1000 Then ListBox1.Items.Add(bs)
Next
End If
End If
Next
End Sub
End Class
我可以帮你做,价格私下谈,不收订金
这东西懂的人少
绛旓細閬嶅巻鐨勪緥瀛愶細Dim i, j As Integer For i = 0 To DataGridView1.RowCount - 1 For j = 0 To DataGridView1.ColumnCount - 1 MsgBox(DataGridView1.Item(j, i).Value)Next Next 娉ㄦ剰锛氫笌Excel鐨勫崟鍏冩牸鍛藉悕瑙勫垯涓嶄竴鏍凤紝杩欓噷鐨 Item(j, i) 涓紝鍒楀彿 j 鍦ㄥ墠锛岃鍙 i 鍦ㄥ悗銆
绛旓細End If If InContainer.Controls.Item(i).Controls.Count <> 0 Then GetAllControls(InContainer.Controls.Item(i), GetList) End If Next End Sub杩欐浠g爜鍙锛屼絾涓嶈兘閬嶅巻鑿滃崟鍜屽伐鍏锋爮锛岃鎸夐渶瑕佷慨鏀
绛旓細鍙互鐨勶紝闇瑕佸垽鏂帶浠剁被鍨嬪苟鍋氫竴涓嬬被鍨嬭浆鎹侳or Each c As Control In Me.Controls If TypeOf(c) Is TextBox Then Dim t As TextBox = CType(c ,TextBox)'璋冪敤t鐨勬柟娉曞嵆鍙 End If Next
绛旓細vb.net锛欴im path = System.IO.Directory.GetFiles("D:\Log\abc", "*.txt", SearchOption.AllDirectories)锛氭悳绱㈣璺緞涓嬬殑鎵鏈txt绫诲瀷鐨勭洰褰曞強瀛愮洰褰 path.AddRange(path)Dim _RecordInfo As String Dim _Reader As StreamReader _Reader = New StreamReader(file, System.Text.Encoding.Default)锛...
绛旓細缁欎綘涓涓彁绀哄惂锛佸懙鍛碉紝鍓╀笅鐨勮鑷繁鎬濊冨摝锛丳ath锛氭槸鍒濆鐩綍鐨勮矾寰 Private Sub WriteArray(ByVal Path As String)'鍐欏叆鏁扮粍浠g爜鍦ㄨ繖閲岋紝鐩存帴灏哖ath鍐欏埌鏁扮粍灏辫浜嗐侱im dir As New IO.DirectoryInfo(Path)For Each d As IO.DirectoryInfo In dir.GetDirectories WriteArray(d.FullName) '閫掑綊 N...
绛旓細ComboBox) Then Dim cb As System.Windows.Forms.ComboBox = DirectCast(ct, System.Windows.Forms.ComboBox) cb.SelectedIndex = -1 End If NextEnd Sub鍥犱负textbox鍦ㄧ獥浣撻噷鐨刾anel閲岋紝浣犲彧閬嶅巻绐椾綋鐨勬帶浠舵槸涓嶅鐨勩
绛旓細GetWindowText()鎴朣endMessage()閮芥棤娉曞彇寰vb绋嬪簭鐨刲abel鐨勬枃瀛,鍥犱负vb鐨刲abel娌℃湁handle, 浣嗗ぇ瀹跺彂鐜 KingSoft CIBA 鍙互鍙栧緱vb鐨刲abel鍊,杩欐槸鍥犱负 KingSoft CIBA 鎷︿笅浜哤in32API涓殑textOut鍑芥暟 鍙傝冭祫鏂欙細http://topic.csdn.net/t/20020312/18/571433.html 鍙傝冭祫鏂欙細http://www.vbgood.com/viewt...
绛旓細娓呭崟 浣跨敤 VB NET 鍒楀嚭璁$畻鏈涓婄殑鎵鏈浜嬩欢鏃ュ織 Public Function GetEventLogs() As String() Dim logs(EventLog GetEventLogs Length ) As String Dim i As Integer = For Each el As EventLog In EventLog GetEventLogs() logs(i) = el Log i += Next Return logs End Function 鎮ㄥ彲浠ョ湅鍒 ...
绛旓細Assembly assembly = typeof("褰撳墠绋嬪簭闆嗗悕绉").Assembly;//鎴朅ssembly assembly = Assembly.GetExecutingAssembly();//褰撳墠绋嬪簭闆唂oreach (Type type in assembly.GetTypes()){ Console.WriteLine(type.FullName); //if(type.FullName.EndsWith(Student)) Console.WriteLine("found");} ...
绛旓細杩欎釜鍒嗕袱涓楠ゃ傜涓姝ユ槸鍒╃敤 System.IO.DirectoryInfo 绫荤殑 GetDirectories() 鏂规硶锛岄亶鍘鎸囧畾鐩綍涓嬬殑鎵鏈瀛愮洰褰曘傜浜屾鏄埄鐢 System.IO.DirectoryInfo 绫荤殑 GetFiles() 鏂规硶锛岄亶鍘嗚繖浜涘瓙鐩綍锛堝寘鎷牴鐩綍锛変笅鐨勬墍鏈夋枃浠躲傚師鐞嗗氨鏄繖鏍凤紝浠g爜鍙弬鑰冿細http://blog.csdn.net/aspnet2002web/article/...