|
-
Oct 12th, 2007, 04:37 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [1.0/1.1] Creating a hidden folder.
Hi. Does anyone know what is the setting to hide a folder when it is created? I know how to create a normal folder and then go back and change the properties to hidden. But is there any way this could be done when the program created it?
Jennifer.
-
Oct 12th, 2007, 07:48 PM
#2
Re: [1.0/1.1] Creating a hidden folder.
Working with files in C#
The above link shows you all you need to know
-
Oct 12th, 2007, 10:02 PM
#3
Re: [1.0/1.1] Creating a hidden folder.
There is no way with managed code. You can either create a directory o, in .NET 2.0, create a directory with specific security. There is no way to apply attributes as you create the directory. Given that the application of attributes would happen milliseconds after the creation the way you're doing it now, I don't really see the issue.
That said, there may be a way to do what you want with unmanaged code. I'd suggest getting the API Guide and looking at the available functions grouped by functionality, then look at the I/O related group(s) to see if there's a function that looks like it might be useful.
-
Oct 18th, 2007, 02:14 PM
#4
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Creating a hidden folder.
I got it to work with this:
if(!Directory.Exists(@"c:\folder\"))
{
DirectoryInfo DInfor = Directory.CreateDirectory(@"c:\folder\");
DInfor.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
}
Thanks for the help.
Jennifer
-
Oct 18th, 2007, 06:32 PM
#5
Re: [RESOLVED] [1.0/1.1] Creating a hidden folder.
But that's doing exactly what you said you could already do: create the folder and then set the hidden attribute.
-
Oct 18th, 2007, 07:48 PM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] [1.0/1.1] Creating a hidden folder.
Sorry for the misunderstanding. What I meant was I know how to create a folder from a program and then manually right click on the folder and check the hidden attribute. I wanted to know how to hide the folder without doing it manually i.e. from within the program.
Jennifer.
-
Oct 18th, 2007, 08:10 PM
#7
Re: [RESOLVED] [1.0/1.1] Creating a hidden folder.
Hopefully that demonstrates why it's important to state clearly what you mean rather than assuming that we know. If you say this:
I know how to create a normal folder and then go back and change the properties to hidden.
in a programming forum then people will assume you mean programmatically. Had you made it plain that the actual problem was that you just didn't know how to make a folder hidden then I could have provided the solution straight away and saved you a few days. The creation of the directory was a red herring, because setting attributes is done on existing directories, whether you just created them or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|