我在vb.net中有一个文件浏览器,我放置了一个字段和一个按钮,当我在该字段中键入文件夹,文档,图像或任何其他文件的名称,然后单击该按钮时,它将进行搜索文件,如果找不到文件,则显示具有相同名称的文件,或者没有大小写的文件都没有输入名称,就像Windows拥有的文件浏览器一样。可以这样做吗?
我将整个项目的代码放在一起,以更好地了解我的代码如何工作。
embedding_size = 100
vocab_size = len(word_to_idx.keys())
num_units = 100
batch_size=5
Margin = 20
tf.reset_default_graph()
# takes input if batch_size is 5, input_data shape will be 10
# First 5 rows hold question vector, remaining 5 hold answer vectors
# Correct answer for question at index 0 will be at index 5
input_data = tf.placeholder(dtype=tf.int64,shape=[None,100])
embedding_matrix = embeddings = tf.Variable(tf.random_uniform([vocab_size, embedding_size], -1.0, 1.0))
embed = tf.nn.embedding_lookup(embedding_matrix, input_data)
with tf.name_scope("Encoder"):
encoder_lstm_cell = tf.nn.rnn_cell.LSTMCell(num_units)
a_, b_ = tf.nn.dynamic_rnn(cell=encoder_lstm_cell,inputs=embed,dtype=tf.float32)
value = tf.transpose(a_, [1, 0, 2])
last = tf.gather(value, int(value.get_shape()[0]) - 1)
# to calculate the similarity
normalized = tf.nn.l2_normalize(last, dim = 1)
prod = tf.matmul(normalized, normalized, adjoint_b = True )
prod = prod[:batch_size,batch_size:]
# similarity between question and correct answers
TA = tf.diag_part(prod)
# similarity between question and false answers
FA = tf.linalg.set_diag(prod,[0]*batch_size)
FA = tf.reduce_max(FA,axis=1)
# loss function and optimizer
substract_ = Margin + FA - TA
loss = tf.reduce_mean(tf.maximum(0.,substract_))
optimizer = tf.train.AdamOptimizer(learning_rate=0.01).minimize(loss)
这是要键入的字段的命令和按钮的命令:
Imports System.IO
Public Class Form1
Dim path As String
Dim nextPath As String
Public Property ListView1 As Object
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
path = TextBox1.Text
If (My.Computer.FileSystem.DirectoryExists(path)) Then
explorer.Clear()
For Each i In My.Computer.FileSystem.GetDirectories(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 2)
Next
For Each i In My.Computer.FileSystem.GetFiles(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 1)
Next
Else
MsgBox("Its A File")
'or user
'pocess.Start(path) // to open the file
End If
Catch ex As Exception
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
path = "C:\Program Files (x86)"
For Each i In My.Computer.FileSystem.GetDirectories(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 2)
Next
For Each i In My.Computer.FileSystem.GetFiles(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 1)
Next
Catch ex As Exception
MsgBox("Não foi encontrado o caminho 'C:\Program Files (x86)' na rede. Entre em contato com o setor de TI.")
Application.Exit()
End Try
End Sub
Private Sub ListView1_ItemSelectionChanged(sender As Object, e As ListViewItemSelectionChangedEventArgs) Handles explorer.ItemSelectionChanged
nextPath = path + "\" + e.Item.Text
End Sub
Private Sub ListView1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles explorer.MouseDoubleClick
Try
If (My.Computer.FileSystem.DirectoryExists(nextPath)) Then
path = nextPath
explorer.Clear()
TextBox1.Text = path
For Each i In My.Computer.FileSystem.GetDirectories(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 2)
Next
For Each i In My.Computer.FileSystem.GetFiles(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 1)
Next
Else
Process.Start(path & "\" & explorer.SelectedItems(0).Text)
End If
Catch ex As Exception
MsgBox("Voçe não tem acesso a esse arquivo, feche o aplicativo e abra o novamente.")
End Try
End Sub
Private Sub BtnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
Try
nextPath = path.Substring(0, path.LastIndexOf("\"))
path = nextPath
explorer.Clear()
TextBox1.Text = path
For Each i In My.Computer.FileSystem.GetDirectories(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 2)
Next
For Each i In My.Computer.FileSystem.GetFiles(path)
explorer.Items.Add(i.Substring(i.LastIndexOf("\") + 1), ImageList1.Images.Count() - 1)
Next
Catch ex As Exception
MsgBox("Não é possivel voltar mais, o aplicativo 'Instruções de Trabalhos Técnicos' irá reiniciar.")
Application.Restart()
End Try
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
End Class