For Each i In My.Computer.FileSystem.Drives
10年積累的成都網(wǎng)站制作、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有虎丘免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Dim FSW As New FileSystemWatcher
FSW.NotifyFilter = NotifyFilters.FileName
FSW.Path = i.Name.ToString
FSW.Filter = "*.txt"
AddHandler FSW.Changed, AddressOf FileSystemWatcher1_Changed '與FileSystemWatcher1_Changed事件綁定,以下同。
AddHandler FSW.Created, AddressOf FileSystemWatcher1_Created
AddHandler FSW.Deleted, AddressOf FileSystemWatcher1_Deleted
AddHandler FSW.Disposed, AddressOf FileSystemWatcher1_Disposed
AddHandler FSW.Error, AddressOf FileSystemWatcher1_Error
AddHandler FSW.Renamed, AddressOf FileSystemWatcher1_Renamed
FSW.EnableRaisingEvents = True
Next
上面代碼放到一個(gè)調(diào)用過(guò)程中
Private Sub FileSystemWatcher1_Created(sender As Object, e As FileSystemEventArgs) Handles FileSystemWatcher1.Created
‘我用fsw的path屬性區(qū)別多個(gè)分區(qū),你用自己的代碼就行,如果你沒(méi)有創(chuàng)建FileSystemWatcher1,就把Handles FileSystemWatcher1.Created刪除。
If sender.path = "C:\" Then
'代碼
ElseIf sender.path = "D:\" Then
'代碼
ElseIf sender.path = "F:\" Then
ElseIf sender.path = "H:\" Then
'……
End If
End Sub
把變量定義時(shí)增加Shared關(guān)鍵字即可.如:
Private
Shared
AAA
As
String
Public
Shared
AAA
As
String
......
這樣AAA在一個(gè)應(yīng)用程序里就是公用的.
------------------------------------------------------
補(bǔ)充:
不可能沒(méi)用,我都是這樣做的.
該控件使用中,自己看吧:
Public
Class
CMB_MemoryTextBox
Inherits
TextBox
#Region
"
變量定義
"
Private
Shared
p_HisData
As
STRU_DATA
'用數(shù)據(jù)表保存所有控件的歷史記錄
Private
Shared
p_FileName
As
String
'保存歷史記錄的文件名
......
我想了兩種思路,winform沒(méi)有findControl,只有個(gè)this.Controls.Contains("textBox1"),因此除了遍歷沒(méi)辦法了。。。
思路1:遍歷Controls,具體你自己完善下,
if(this.Controls.Count0)
{
foreach(Control c in this.Controls)
if(c.GetTepy==Tepyof(TextBox))
string str += ((TextBox)c).Text;
}