DirectoryInfo()和DirectoryInfo有什么区别
Dim dir As String = Directory.GetCurrentDirectoryDim dir3 As DirectoryInfo = New DirectoryInfo(dir).Root
Dim dir1 As DirectoryInfo() = dir3.GetDirectories
Dim aa As DirectoryInfo
Dim bb As String
For Each aa In dir1
bb = bb & aa.Name & ControlChars.CrLf
next
为什么程序里的 Dim dir1 As DirectoryInfo() = dir3.GetDirectories只能用DirectoryInfo(),
而用DirectoryInfo就会报错 --------------------编程问答-------------------- GetDirectories 返回的是一个数组 --------------------编程问答-------------------- 我也想知道它们的区别及用法 帮顶 --------------------编程问答--------------------
DirectoryInfo 目录信息
DirectoryInfo() 目录信息数组 VB.NET
DirectoryInfo[] 目录信息数组 C#
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dir As String = IO.Directory.GetCurrentDirectory()
Dim dir3 As IO.DirectoryInfo = New IO.DirectoryInfo(dir).Root
Dim dir1 As IO.DirectoryInfo() = dir3.GetDirectories
Dim aa As IO.DirectoryInfo
Dim bb As String
For Each aa In dir1
bb = bb & aa.Name & ControlChars.CrLf
Next
MessageBox.Show(bb)
End Sub
--------------------编程问答-------------------- 因为dir3.GetDirectories返回的是一个DirectoryInfo数组.所以要用DirectoryInfo()来接收
private void button6_Click(object sender, EventArgs e)
{
string dir = Directory.GetCurrentDirectory();
DirectoryInfo dir3 = new DirectoryInfo(dir).Root;
DirectoryInfo[] dir1 = dir3.GetDirectories();
string bb="";
foreach (DirectoryInfo aa in dir1)
bb += aa.Name + "\n";
MessageBox.Show(bb);
}
DirectoryInfo只是表示单个文件夹 --------------------编程问答-------------------- 2楼挖了个坟贴,刚注意到,这贴是不会结了。 --------------------编程问答-------------------- --------------------编程问答--------------------
??? --------------------编程问答--------------------
3年前的帖子了。。。。。。。 --------------------编程问答--------------------
呵呵,愣是没看出来…… --------------------编程问答-------------------- 发表于:2007-03-25 00:27:38
补充:.NET技术 , VB.NET