Results 1 to 4 of 4

Thread: How to set file attribute?

  1. #1
    Join Date
    Nov 2009
    Posts
    61

    How to set file attribute?

    Hey folks,

    I am a software programmer and i am at beginning stage so i am not much familiar with the setting file attribute in programming.
    So I want to know how to set the file attribute for different language, like VB, VB.net, C, C++ etc.

    If anyone know please help me out.
    Last edited by Julli_gaada; 21-11-2009 at 06:35 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    586

    Re: How to set file attribute?

    Hey Friend,

    Here i am giving you some codes for setting file attribute just use them as per your requirement.

    To set a file attribute of the VB:
    Code:
    Public Shared Sub SetAttributes ( _path As String, _fileAttributes As FileAttributes _)
    
    Dim path As String
    Dim fileAttributes As FileAttributes
    File.SetAttributes(path, fileAttributes)
    To set a file attribute of the C#:

    Code:
    public static void SetAttributes(string path, FileAttributes fileAttributes)
    Hope it will works

  3. #3
    Join Date
    Apr 2008
    Posts
    397

    Re: How to set file attribute?

    You can also use a well known command for setting the file attribute is "ATTRIB"

    If you want to set a file attribute to archive and to remove archive:
    Code:
    attrib +a filename
    Code:
    attrib -a filename

    For setting system file attribute and to remove system file attribute:
    Code:
    attrib +s filename
    Code:
    attrib -s filename

    For setting hidden attribute and to remove hidden attribute:
    Code:
    attrib +h filename
    Code:
    attrib -h filename

    For setting read only attribute and to remove read only attribute:
    Code:
    attrib +r filename
    Code:
    attrib -r filename

  4. #4
    Join Date
    Apr 2008
    Posts
    439

    Re: How to set file attribute?

    ATTRIB used to displays, sets, or removes the read-only, archive, system, and hidden attributes assigned to files or directories. Used without parameters, attrib displays attributes of all files in the current directory.
    Syntax

    attrib [{+r|-r}] [{+a|-a}] [{+s|-s}] [{+h|-h}] [[Drive:][Path] FileName] [/s[/d]]

    Parameters

    +r : Sets the read-only file attribute.

    -r : Clears the read-only file attribute.

    +a : Sets the archive file attribute.

    -a : Clears the archive file attribute.

    +s : Sets the system file attribute.

    -s : Clears the system file attribute.

    +h : Sets the hidden file attribute.

    -h : Clears the hidden file attribute.

    [ Drive : ][ Path ] FileName : Specifies the location and name of the directory, file, or set of files for which you want to display or change attributes. You can use wildcard characters (that is, ? and *) in the FileName parameter to display or change the attributes for a group of files.

    /s : Applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.

    /d : Applies attrib and any command-line options to directories.

    /? : Displays help at the command prompt.

    Thank you

Similar Threads

  1. How to modify file attribute in Windows 7?
    By seema_thk in forum Operating Systems
    Replies: 5
    Last Post: 05-01-2010, 09:39 PM
  2. How to set HTML Tag Attribute in asp.net
    By Shashee in forum Software Development
    Replies: 3
    Last Post: 08-06-2009, 10:39 PM
  3. Howto add new attribute via LDIF file
    By Manolax in forum Active Directory
    Replies: 1
    Last Post: 11-11-2008, 05:57 PM
  4. Custom AD attribute - [WP]
    By OmJaa in forum Active Directory
    Replies: 3
    Last Post: 11-03-2008, 07:17 PM
  5. Change Read-Only Attribute
    By William Colls in forum Vista Help
    Replies: 2
    Last Post: 18-02-2008, 04:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •