illustrates the FileAttributes enumeration : File « File Stream « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Class Interface
3. Collections Data Structure
4. Components
5. Data Types
6. Database ADO.net
7. Design Patterns
8. Development Class
9. Event
10. File Stream
11. Generics
12. GUI Windows Form
13. Language Basics
14. LINQ
15. Network
16. Office
17. Reflection
18. Regular Expressions
19. Security
20. Services Event
21. Thread
22. Web Services
23. Windows
24. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorial
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » File Stream » FileScreenshots 
illustrates the FileAttributes enumeration
illustrates the FileAttributes enumeration

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

 /*
  Example15_4.cs illustrates the FileAttributes enumeration
*/

using System;
using System.Windows.Forms;
using System.IO;

public class Example15_4 
{

  // the DecipherAttributes method turns file attributes
  // into something easier for people to read
  public static void DecipherAttributes(FileAttributes f
  {
    if ((f & FileAttributes.Archive== FileAttributes.Archive)
      Console.WriteLine("Archive");
    if ((f & FileAttributes.Compressed== FileAttributes.Compressed)
      Console.WriteLine("Compressed");
    if ((f & FileAttributes.Device== FileAttributes.Device)
      Console.WriteLine("Device");
    if ((f & FileAttributes.Directory)   == FileAttributes.Directory)
      Console.WriteLine("Directory");
    if ((f & FileAttributes.Encrypted)  == FileAttributes.Encrypted)
      Console.WriteLine("Encrypted");
    if ((f & FileAttributes.Hidden)  == FileAttributes.Hidden)
      Console.WriteLine("Hidden");
    if ((f & FileAttributes.NotContentIndexed)  == FileAttributes.NotContentIndexed)
      Console.WriteLine("NotContentIndexed");
    if ((f & FileAttributes.Offline)  == FileAttributes.Offline)
      Console.WriteLine("Offline");
    if ((f & FileAttributes.ReadOnly)  == FileAttributes.ReadOnly)
      Console.WriteLine("ReadOnly");
    if ((f & FileAttributes.ReparsePoint)  == FileAttributes.ReparsePoint)
      Console.WriteLine("ReparsePoint");
    if ((f & FileAttributes.SparseFile)  == FileAttributes.SparseFile)
      Console.WriteLine("SparseFile");
    if ((f & FileAttributes.System)  == FileAttributes.System)
      Console.WriteLine("System");
    if ((f & FileAttributes.Temporary)  == FileAttributes.Temporary)
      Console.WriteLine("Temporary");
  }
    
    [STAThread]
  public static void Main() 
  {

    // create and show an open file dialog
    OpenFileDialog dlgOpen = new OpenFileDialog();
    if (dlgOpen.ShowDialog() == DialogResult.OK)
    {
      // retrieve and show the file attributes
      FileAttributes f = File.GetAttributes(dlgOpen.FileName);
      Console.WriteLine("Filename " + dlgOpen.FileName +
        " has attributes:");
      DecipherAttributes(f);
    }

  }

}


           
       
Related examples in the same category
1. Get file Creation TimeGet file Creation Time
2. Delete a file
3. Get File Access Control
4. illustrates the FileInfo classillustrates the FileInfo class
5. illustrates the FileSystemWatcher classillustrates the FileSystemWatcher class
6. File class to check whether a file exists, open and read
7. Uses methods in the File class to check whether a file exists
8. Uses methods in the File class to check the status of a file
w_w_w__.___ja___v_a___2__s._c___o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.