April 13, 2009 at 4:42 pm
Perry Whittle (4/13/2009)
RBarryYoung (4/13/2009)
I apologize, but unfortunately, because of conflicts between VS 2005/.net 2.0 and VS 2008/.net 3.5, my SMO dev environment is down right now so I cannot effectively test anything.I have never used EnumDirectories (though I intend to real soon) however from BOL I get this:
Public Function EnumDirectories ( _
path As String _
) As DataTable
So I would assume the something like this ought to work:
dTable = srv.EnumDirectories("C:\")
Does that not work for you?
do you not have to provide a depth level too though, i see the output from xp_dirtree. How does that relate to EnumDirectories
I don't think that you have that option, SMO just sticks a 1 in for you.
If there is something in SMO that exposes "xp_dirtree" fully, I haven't found it yet.
Of course, you can just EXEC xp_dirtree yourself, you know. 🙂
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 13, 2009 at 4:47 pm
yes, i thought of that but running it through SSMS the query takes a short while and thats just on my laptop. Imagine on a server with 4 or more logical drives. DirectoryInfo class does seem to be a hell of a lot quicker but you cant use it remotely AFAIK 🙁
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
April 13, 2009 at 5:05 pm
Florian Reischl (4/13/2009)
RBarryYoung (4/13/2009)
hmm, why two backslashes ("\\"), Florian? Or is that just a C# thing?It's a C(#) thing. Like in C or C++ you can specify special characters in strings. The characters are marked with "\" so you have to mask a backslash with an additional one. The other way is to quote the whole string with a @:
VB:
Dim str As String = "Hello" & vbCrLf & "World" & vbTab & "Anything"
C#:
string str = "Hello\rWorld\t";
VB:
Dim str As String = "C:\Temp\Anywhere"
C#:
string str = "C:\\Temp\\Anywhere";
or
string str = @"C:\Temp\Anywhere";
Usually I use the doubled backslash except in long directory paths.
Greets
Flo
thanks Flo. I do program in C#/etc. sometimes, but I never did learn all of it's special character sequences. Good to know.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 13, 2009 at 5:09 pm
Perry Whittle (4/13/2009)
yes, i thought of that but running it through SSMS the query takes a short while and thats just on my laptop. Imagine on a server with 4 or more logical drives. DirectoryInfo class does seem to be a hell of a lot quicker but you cant use it remotely AFAIK 🙁
Heh, yeah, even the DirectoryInfo class would be dog slow if I asked it to enumerate my C: drive's entire folder tree!
If you just want to browse from a TreeView, EnumDirectories should be sufficient. Just catch the Expand(?) event and then enumerate the subfolders of whatever node was expanded. That's what I would do anyway. 🙂
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply