Go Back   TechArena Community > Software > Tips & Tweaks
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to set file attribute?

Tips & Tweaks


Reply
 
Thread Tools Search this Thread
  #1  
Old 21-11-2009
Member
 
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.
Reply With Quote
  #2  
Old 21-11-2009
Member
 
Join Date: Apr 2008
Posts: 584
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
Reply With Quote
  #3  
Old 21-11-2009
Member
 
Join Date: Apr 2008
Posts: 395
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
Reply With Quote
  #4  
Old 21-11-2009
Member
 
Join Date: Apr 2008
Posts: 434
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
Reply With Quote
Reply

  TechArena Community > Software > Tips & Tweaks
Tags: , , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 03:01 AM.