Home All Groups Group Topic Archive Search About

Seeting File Attrubites

Author
16 Apr 2005 5:19 PM
Husam
Hi EveryBody:

I want to set the file attribute to Hidden and readOnly proprty by using
this:
System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\home", FileAttributes.ReadOnly)

System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\kernel32dll", FileAttributes.Hidden)
But i foucs that:

when I run my program it just take the last attributes, which is hidden and
ignor readonly, I want to set the both property to one file, How can I do
that ?

any help will be appreciated

regard's

Husam

Author
16 Apr 2005 6:02 PM
Chris
Husam wrote:
Show quoteHide quote
> Hi EveryBody:
>
> I want to set the file attribute to Hidden and readOnly proprty by using
> this:
>
> System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\home", FileAttributes.ReadOnly)

> System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\kernel32dll", FileAttributes.Hidden)
> But i foucs that:
>
> when I run my program it just take the last attributes, which is hidden and
> ignor readonly, I want to set the both property to one file, How can I do
> that ?
>
> any help will be appreciated
>
> regard's
>
> Husam          

Not tested but try:
System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\kernel32dll",
FileAttributes.Hidden Or FileAttributes.ReadOnly)

Chris
Author
16 Apr 2005 6:23 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Husam" <Hu***@discussions.microsoft.com> schrieb:
> I want to set the file attribute to Hidden and readOnly proprty by using
> this:
>
> System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\home",
> FileAttributes.ReadOnly)
>
> System.IO.File.SetAttributes("C:\windows98\windowsdll\win32app\direction\kernel32dll",
> FileAttributes.Hidden)
> But i foucs that:
>
> when I run my program it just take the last attributes, which is hidden
> and
> ignor readonly, I want to set the both property to one file, How can I do
> that ?

First, you are setting the attributes on different files/folders.  Second,
you may want to preserve existing arguments and combine 'ReadOnly' and
'Hidden':

\\\
Imports System.IO
..
..
..
File.SetAttributes( _
    FileName, _
    File.GetAttributes(FileName) Or _
    FileAttributes.Hidden Or _
    FileAttributes.ReadOnly _
)
///

Related:

<URL:http://groups.google.de/groups?selm=OduQMSILFHA.4028%40tk2msftngp13.phx.gbl>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>