---------- Forwarded message ----------
From: Cerebrus <[email protected]>
Date: Thu, 11 Jun 2009 10:35:38 -0700 (PDT)
Subject: [DotNetDevelopment] Re: Change specific folder properties
To: "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" <[email protected]>


Darn it... Didn't read the "VB" part of the question! Well, you can
use an online converter to convert the sample to VB.

On Jun 11, 10:34 pm, Cerebrus <[email protected]> wrote:
> The DirectoryInfo class exposes an "Attributes" property which is a
> Flags enumeration on the FileAttributes enumeration. You should note
> that a Directory is basically a file with a special attribute -
> "Directory". Therefore, you should not clear that attribute, rather
> you should always append to the existing enumerated value or remove
> from it.
>
> Here's a very simple Console app to demonstrate the concept.
>
> ---
> class Program
> {
>   static void Main(string[] args)
>   {
>     string input = args[0];
>     if(input == "hide")
>     {
>       ToggleHidden(true);
>     }
>     else if(input == "reveal")
>     {
>       ToggleHidden(false);
>     }
>   }
>
>   private static void ToggleHidden(bool hide)
>   {
>     DirectoryInfo d = new DirectoryInfo(@"C:\MySecretFolder");
>     if(d.Exists)
>     {
>       FileAttributes atts = d.Attributes;
>       if(hide == true)
>       { // Hide the folder.
>         // Append Hidden attribute only if not already set.
>         if((atts & FileAttributes.Hidden) != FileAttributes.Hidden)
>           atts |= FileAttributes.Hidden;
>       }
>       else
>       {  // Show the folder.
>         // Remove Hidden attribute if set.
>         if((atts & FileAttributes.Hidden) == FileAttributes.Hidden)
>           atts &= ~FileAttributes.Hidden;
>       }
>
>       d.Attributes = atts;
>     }
>   }
>
> }
>
> ---
>
> In the same way you can set/unset other attributes such as ReadOnly/
> Archive, etc.
>
> On Jun 11, 6:48 pm, LostVB <[email protected]> wrote:
>
>
>
> > I am usning VB Express 2008 and trying to change specific folder
> > properties. I would like to set/unset - "show hidden files and
> > folders" property. But I can't find any examples or even a direction
> > to look/- Hide quoted text -
>
> - Show quoted text -

Reply via email to