vb.net搜索网络驱动器 [英] vb.net search network drive

查看:90
本文介绍了vb.net搜索网络驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是VB.NET和编程的新手。我已经用vb.net自学了很多基础知识,但我仍然是新手。

我现在正在开发一个小应用程序,我需要一些帮助一个

部分代码。单击一个按钮时,我需要将它发送到网络驱动器位置,并计算一个文件扩展名为

的文件数量。然后将该数字存储在声明的变量中。

这可能吗?有人可以帮忙吗?此外,这会被称为

方法,函数或事件过程吗?还不确定

的差异是什么。

Hello, I am new to VB.NET and programming in general. I have taught
myself a lot of the basics with vb.net but am still quite the novice.
I am working on a little application now and I need some help with one
part of the code. When a button is clicked I need to have it go out to
a network drive location and count how many files are present with a
certain file extension. Then store that number in a declared variable.
Is this possible? Can someone help? Also, would this be called a
method, function, or event procedure? Not exactly sure what the
difference is yet.

推荐答案

3月9日上午11:12 ,电脑怪人 < JohnTAl ... @ gmail.comwrote:
On Mar 9, 11:12 am, "Computer geek" <JohnTAl...@gmail.comwrote:

你好,我是VB.NET和编程的新手。我已经用vb.net自学了很多基础知识,但我仍然是新手。

我现在正在开发一个小应用程序,我需要一些帮助一个

部分代码。单击一个按钮时,我需要将它发送到网络驱动器位置,并计算一个文件扩展名为

的文件数量。然后将该数字存储在声明的变量中。

这可能吗?有人可以帮忙吗?此外,这会被称为

方法,函数或事件过程吗?还不确定

的差异是什么。
Hello, I am new to VB.NET and programming in general. I have taught
myself a lot of the basics with vb.net but am still quite the novice.
I am working on a little application now and I need some help with one
part of the code. When a button is clicked I need to have it go out to
a network drive location and count how many files are present with a
certain file extension. Then store that number in a declared variable.
Is this possible? Can someone help? Also, would this be called a
method, function, or event procedure? Not exactly sure what the
difference is yet.



这是我很久以前为另一张海报写过的快速模块。

小心我刚刚对它进行了空气修改让你指定扩展名

类型,这样它可能会有一些错误。您应该能够修改

程序来计算文件并返回该值。


让我知道它是如何工作的(如果你需要的话)帮助修改它)


谢谢,


Seth Rowe

模块模块1


Sub Main()

ListAllFiles(" C:/"," exe")

Console.WriteLine(" done")

Console.Read()

结束子


''只传递扩展名--ie只需exe不用.exe或* .exe

Private Sub ListAllFiles(ByVal path As String,ByVal extension As

String)

试试

Dim filenames()As String =

System.IO.Directory.GetFiles(path,String.Format(" *。{0}",extension)

For i As Int16 = 0 to filenames.Length - 1

''这里可能会增加你的柜台

Console.WriteLine(filenames(i))

下一页

Dim directories()As String =

System.IO.Directory.GetDirectories(path)

For我作为Int16 = 0到目录。长度 - 1

ListAllFiles(目录(i),扩展名)

下一页

Catch ex As Exception

''什么都不做

结束尝试

结束子


结束模块

Here''s a quick module that I wrote a long time ago for another poster.
Beware I air-modified it just now to let you specify the extension
type so it might have some bugs. You should be able to modify the
procedure to count the files and return that value.

Let me know how it works out (or if you need any help modifying it)

Thanks,

Seth Rowe
Module Module1

Sub Main()
ListAllFiles("C:/", "exe")
Console.WriteLine("done")
Console.Read()
End Sub

'' Pass just the extension --i.e. just exe not .exe or *.exe
Private Sub ListAllFiles(ByVal path As String, ByVal extension As
String)
Try
Dim filenames() As String =
System.IO.Directory.GetFiles(path, String.Format("*.{0}", extension)
For i As Int16 = 0 To filenames.Length - 1
'' Possibly increment your counter here
Console.WriteLine(filenames(i))
Next
Dim directories() As String =
System.IO.Directory.GetDirectories(path)
For i As Int16 = 0 To directories.Length - 1
ListAllFiles(directories(i), extension)
Next
Catch ex As Exception
'' do nothing
End Try
End Sub

End Module


计算机geek写道:
Computer geek wrote:

您好,我是VB.NET和编程的新手。我有教授

我自己很多基础知识th vb.net但我仍然是新手。

我现在正在开发一个小应用程序,我需要一些帮助,其中一个代码是
的一部分。单击一个按钮时,我需要将它发送到网络驱动器位置,并计算一个文件扩展名为

的文件数量。然后将该数字存储在声明的变量中。

这可能吗?有人可以帮忙吗?此外,这会被称为

方法,函数或事件过程吗?还不确定

的差异是什么。
Hello, I am new to VB.NET and programming in general. I have taught
myself a lot of the basics with vb.net but am still quite the novice.
I am working on a little application now and I need some help with one
part of the code. When a button is clicked I need to have it go out to
a network drive location and count how many files are present with a
certain file extension. Then store that number in a declared variable.
Is this possible? Can someone help? Also, would this be called a
method, function, or event procedure? Not exactly sure what the
difference is yet.



如果您想要计算文件,以下代码将执行

正是如此(注意换行) -


Dim sFiles()As String = Directory.GetFiles(" C:\ Windows"," *。 exe",

SearchOption.AllDirectories)

MsgBox(String.Format(找到的EXE文件数= {0},UBound(sFiles) - 1) )

ShaneO


有10种人 - 那些了解Binary和那些

的人不是。

If you are wanting to Count the files, the following code will do
exactly that (watch for line wrapping) -

Dim sFiles() As String = Directory.GetFiles("C:\Windows", "*.exe",
SearchOption.AllDirectories)
MsgBox(String.Format("Number of EXE Files Found = {0}", UBound(sFiles) - 1))
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don''t.


ShaneO写道:
ShaneO wrote:

计算机geek写道:
Computer geek wrote:

>您好,我是VB.NET和编程的新手。我已经用vb.net自学了很多基础知识,但我仍然是新手。
我现在正在开发一个小应用程序,我需要一些帮助。码。单击一个按钮时,我需要将它发送到网络驱动器位置,并计算具有特定文件扩展名的文件数量。然后将该数字存储在声明的变量中。
这可能吗?有人可以帮忙吗?此外,这会被称为
方法,函数或事件过程吗?还不确定
差异是什么。
>Hello, I am new to VB.NET and programming in general. I have taught
myself a lot of the basics with vb.net but am still quite the novice.
I am working on a little application now and I need some help with one
part of the code. When a button is clicked I need to have it go out to
a network drive location and count how many files are present with a
certain file extension. Then store that number in a declared variable.
Is this possible? Can someone help? Also, would this be called a
method, function, or event procedure? Not exactly sure what the
difference is yet.



如果您想要计算文件,下面的代码将会执行
$ b $确切地说(注意换行) -


Dim sFiles()As String = Directory.GetFiles(" C:\ Windows"," * .exe,

SearchOption.AllDirectories)

MsgBox(String.Format("发现的EXE文件数= {0}),UBound(sFiles) -

1))


ShaneO


有10种人 - 了解Binary和那些
$ b的人$ b不要。


If you are wanting to Count the files, the following code will do
exactly that (watch for line wrapping) -

Dim sFiles() As String = Directory.GetFiles("C:\Windows", "*.exe",
SearchOption.AllDirectories)
MsgBox(String.Format("Number of EXE Files Found = {0}", UBound(sFiles) -
1))
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don''t.



错误:对不起,第二行应该是+ 1,而不是 - 1。


ShaneO


有10种人 - 那些了解Binary和那些

的人不会。

MISTAKE: Sorry, the second line is supposed to be "+ 1", not "- 1".

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don''t.


这篇关于vb.net搜索网络驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆