tag:blogger.com,1999:blog-546036873798832453.post395462094386436656..comments2023-10-09T06:28:49.766-07:00Comments on PowerShell Scripts Blog: Get-SpecialFolders.ps1Unknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-546036873798832453.post-75158985326765310272011-08-08T23:51:04.092-07:002011-08-08T23:51:04.092-07:00The reason for the plus sign is due to public chil...The reason for the plus sign is due to public child classes. SpecialFolder is a public class nested within the System.Environment class. When referencing public child classes you have to use a + sign. We posted an article about this a while back on the PowerShell blog: http://blogs.msdn.com/b/powershell/archive/2009/08/27/plus-in-net-class-names.aspx<br /><br />-- TomTomhttps://www.blogger.com/profile/07765968047417339431noreply@blogger.comtag:blogger.com,1999:blog-546036873798832453.post-31022788788091936942011-04-21T02:51:56.629-07:002011-04-21T02:51:56.629-07:00David,
I'm not sure why this particular bit o...David,<br /><br />I'm not sure why this particular bit of syntax (i.e. using the "+") works and why normal dotting doesn't. I spent hours trying to figure this out and came up with little to explain it, other than this works. I'd love to know too, but I just chalk it up to 'you just have to know'!<br /><br />Thanks for your comment.Thomas Leehttps://www.blogger.com/profile/05591926562143348089noreply@blogger.comtag:blogger.com,1999:blog-546036873798832453.post-18393639634955886322011-04-20T15:24:07.859-07:002011-04-20T15:24:07.859-07:00I borrowed code from this script. I know how the ...I borrowed code from this script. I know how the code works to get special folders. What I don't know is the syntax:<br />$folders = [system.Enum]::GetValues(<b>[System.Environment+SpecialFolder]</b>)<br /><br />Why System.Environment<b>+</b>SpecialFolder? What is different (other than that System.Environment.SpecialFolder does not work in this instance)?<br /><br />I hate using code without understanding the syntax, though I know what it does, it is frustrating; I have never seen the syntax mentioned anywhere else.David Moisanhttps://www.blogger.com/profile/15246027784687332011noreply@blogger.comtag:blogger.com,1999:blog-546036873798832453.post-57873897436181910192009-08-06T06:39:09.839-07:002009-08-06T06:39:09.839-07:00Thanks for the comment.
I wrote the script simply...Thanks for the comment.<br /><br />I wrote the script simply to enumerate each Special Folder and where on my system it pointed to. I used the ENUM to work out what the set of special folder names were, then I called GetFolderPath to get the path for that folder, which I then display. If I'd wanted to do more things, then using the DirectoryInfo object might have been useful.Thomas Leehttps://www.blogger.com/profile/05591926562143348089noreply@blogger.comtag:blogger.com,1999:blog-546036873798832453.post-87094520381549169812009-08-05T20:32:44.377-07:002009-08-05T20:32:44.377-07:00I'm curious why you choose to return strings n...I'm curious why you choose to return strings not objects (say [System.IO.DirectoryInfo]). I do love the enum trick though, they are my newest friends.slipsechttps://www.blogger.com/profile/18112934964141162776noreply@blogger.com