?
Solved

Quick Question on File Attributes

Posted on 2006-03-19
5
Medium Priority
?
225 Views
Last Modified: 2010-04-23
How do I make the below work?  (hopfully, a solution that doesn't involve much more code than below)

Dim FileAtt As IO.FileAttributes = IO.File.GetAttributes("c:\somefile.txt")
If FileAtt = IO.FileAttributes.Hidden Then fileishidden = True
0
Comment
Question by:stev0931
5 Comments
 

Author Comment

by:stev0931
ID: 16232093
Note that it is the second line that does not work
0
 
LVL 39

Expert Comment

by:appari
ID: 16232124
try this

If FileAtt.Hidden Then fileishidden = True
0
 
LVL 39

Assisted Solution

by:appari
appari earned 300 total points
ID: 16232126
or this
If FileAtt And IO.FileAttributes.Hidden Then fileishidden = True
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 16232136
Hi stev0931;

You will need to do it this way.

        Dim FileAtt As IO.FileAttributes = IO.File.GetAttributes("c:\Temp\TestFile.txt")
        If (FileAtt And IO.FileAttributes.Hidden) = IO.FileAttributes.Hidden Then fileishidden = True


Fernando
0
 
LVL 9

Assisted Solution

by:jrscherer
jrscherer earned 200 total points
ID: 16232359
what about in a single line:

fileishidden = (IO.File.GetAttributes("c:\Temp\TestFile.txt")  And IO.FileAttributes.Hidden) <> 0

or shorter (faster)

fileishidden = cbool (IO.File.GetAttributes("c:\Temp\TestFile.txt")  And IO.FileAttributes.Hidden)

have fun, Jack.net
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question