473,700 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File's custom attributes

How can i read/write file's custom attributs(like subject,author. ..) in

Thanks :))
Nov 15 '05 #1
3 26265
Gets the FileAttributes of the file on the path.

[Visual Basic]
Public Shared Function GetAttributes( _
ByVal path As String _
) As FileAttributes
public static FileAttributes GetAttributes(
string path
public: static FileAttributes GetAttributes(
String* path
public static function GetAttributes(
path : String
) : FileAttributes;
The path to the file.
Return Value
The FileAttributes of the file on the path, or -1 if the path or file is not

Exception Type Condition
ArgumentExcepti on path is empty, contains only white spaces, or
contains invalid characters.
PathTooLongExce ption The specified path, file name, or both exceed the
system-defined maximum length. For example, on Windows-based platforms,
paths must be less than 248 characters, and file names must be less than 260
NotSupportedExc eption path is in an invalid format.
DirectoryNotFou ndException The specified path is invalid, such as
being on an unmapped drive.

The path parameter is permitted to specify relative or absolute path
information. Relative path information is interpreted as relative to the
current working directory. To obtain the current working directory, see
GetCurrentDirec tory.

For an example of using this method, see the Example section below. The
following table lists examples of other typical or related I/O tasks.

To do this... See the example in this topic...
Create a text file. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading Text from a File
Append text to a file. Opening and Appending to a Log File

FileInfo.Append Text

Rename or move a file. File.Move

Read from a binary file. Reading and Writing to a Newly Created Data
Write to a binary file. Reading and Writing to a Newly Created Data
Set file attributes. SetAttributes

[Visual Basic, C#, C++] The following example demonstrates the GetAttributes
and SetAttributes methods by applying the Archive and Hidden attributes to a

[Visual Basic]
Imports System
Imports System.IO
Imports System.Text

Public Class Test
Public Shared Sub Main()
Dim path As String = "c:\temp\MyTest .txt"
' Delete the file if it exists.
If File.Exists(pat h) = False Then
File.Create(pat h)
End If

If (File.GetAttrib utes(path) And FileAttributes. Hidden) =
FileAttributes. Hidden Then
' Show the file.
File.SetAttribu tes(path, FileAttributes. Archive)
Console.WriteLi ne("The {0} file is no longer hidden.", path)
' Hide the file.
File.SetAttribu tes(path, File.GetAttribu tes(path) Or
FileAttributes. Hidden)
Console.WriteLi ne("The {0} file is now hidden.", path)
End If
End Sub
End Class
using System;
using System.IO;
using System.Text;

class Test
public static void Main()
string path = @"c:\temp\MyTes t.txt";
// Delete the file if it exists.
if (!File.Exists(p ath))
File.Create(pat h);

if ((File.GetAttri butes(path) & FileAttributes. Hidden) ==
FileAttributes. Hidden)
// Show the file.
File.SetAttribu tes(path, FileAttributes. Archive);
Console.WriteLi ne("The {0} file is no longer hidden.", path);
// Hide the file.
File.SetAttribu tes(path, File.GetAttribu tes(path) |
FileAttributes. Hidden);
Console.WriteLi ne("The {0} file is now hidden.", path);
#using <mscorlib.dll >

using namespace System;
using namespace System::IO;
using namespace System::Text;

void main() {
String* path = S"c:\\temp\\MyT est.txt";
// Delete the file if it exists.
if (!File::Exists( path)) {
File::Create(pa th);

if ((File::GetAttr ibutes(path) & FileAttributes: :Hidden) ==
FileAttributes: :Hidden) {
// Show the file.
File::SetAttrib utes(path, FileAttributes: :Archive);
Console::WriteL ine(S"The {0} file is no longer hidden.", path);
} else {
// Hide the file.
File::SetAttrib utes(path,
static_cast<Fil eAttributes>(Fi le::GetAttribut es(path) |
FileAttributes: :Hidden));
Console::WriteL ine(S"The {0} file is now hidden.", path);

Duncan McNutt
Microsoft Product Deactivation Team
"StGo" <go******@nes s-isi.com> wrote in message
news:eQ******** ******@TK2MSFTN GP09.phx.gbl...
How can i read/write file's custom attributs(like subject,author. ..) in

Thanks :))

Nov 15 '05 #2
Hi, StGo:
If you mean the summary(auther, title, subject) properties of files
on NTFS or ole ducments, you may want to check out Dsofile activx control
provided by Microsoft. You need to download it from the following link and
import it into your project.


Hope it helps

"StGo" <go******@nes s-isi.com> wrote in message
news:eQ******** ******@TK2MSFTN GP09.phx.gbl...
How can i read/write file's custom attributs(like subject,author. ..) in

Thanks :))

Nov 15 '05 #3

Sank's for answer!

But I'm mean to non standart attributs like subject,comment s and
possibility adding custom attributs
like "custom_version =1.6".

If you can,please help me:)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001a5). Display.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000108). The help for LNK2022 is completely useless:
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI standard). So I downloaded the VC++ 2005 Tools Refresh (http://tinyurl.com/5mdq2). After that I tried to do a full rebuild, but my project wouldn't link anymore. I get the following errors: MSVCMRTD.lib(mstartup.obj) : error LNK2022: metadata...
by: Edward Grosso via .NET 247 | last post by:
Hi to all the dotnet community, I'm actually trying to figure out how can I save a Recordset to an ASCII file with custom field separators, in a fast way, without loops. Perhaps there is some way with a streamwriter object ? Any idea ? Thanks in advance -------------------------------- From: Edward Grosso ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
by: tshad | last post by:
Is there a way to use a custom button with the: <Input ID="MyFile" Type="File" RunAt="Server">? This gives you a generic button, but I would like to use my own button that has the same style as the other buttons I've created. Is there an easy way to do this? Thanks,
by: Julian Jelfs | last post by:
Hi, I had an aspx pag in .Net 1.1 with a label on it. As such I had a code behind page with a declaration for that label. When I convert to Asp.Net 2.0 the code behind is converted to a partial class and the declaration for the label is removed. This is what I expected to happen and I understand why it has happened. The problem I have is that I had added a custom attribute to my label
by: serge calderara | last post by:
Dear all, Let say that I have developped a funcionnal library that I distribute for use. That library can be integrated in a project by referencing it and then use it by calling function and setting properties. So far so good. I would like that some function behaviour can be customized withing config file through custom predifined XML tags.What is the way to be able to configure some property of that libarry inside config file within...
by: steve | last post by:
Hi all, Here's some work in progress that should allow you to run a batch file as a custom action in a VS deployment project. Yup I know you can use js or wsh, but the target may not have either.. Essentially it's just a wrapper for the Process class and a command interpreter. Warning, it only partly works. I had wanted to pass in (a) The name of the batch file (through "BatchFileName"), and
by: Ryan | last post by:
I am trying to log events to SQL Server instead of the computers event log, but, although I get no errors, I have no luck. The webevents_events table is empty. I have a custom event that I am raising (passwordchange), and can see it beign raised successfully...just it seems to go nowhere. I have run aspnet_regsql to setup the database to handle event recording. I am fairly sure I am missing something in my web.config file. (I would...
by: P4trykx | last post by:
Hello I'm want to add some custom attributes to WebControls using WebControl.Attributes.Add("abc","234"); So the html output will look like this, <input type="hidden" abc="123" /etc. I know that I need to modify .dtd file and tell the browser that abc i legal attribute. But I have another problem, I can't change the abc attribute using
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.