General discussion

Locked

How can I get a file's attributes?

By A manager and a programmer ·
Before running a program I want to check a few things about a file that the program will be using, things like when was it created and how big is it. I'm writing in Visual Basic 6. I'm new to VB, having moved from a mainframe environment. I know on the mainframe this kind of information is easy to get.

Any help would be appreciated.

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How can I get a file's attributes?

by peace monger In reply to How can I get a file's at ...

If you are looking for a programmatic way, I'm not sure. If you can get to a command prompt, then MS-DOS can tell you with

ATTRIB filespec
where filespec is the file name or expression (wildcards allowed).

The flags are R for readonly, H for hidden, S for system, and A for archive. Use DIR filespec to get filename, last modified date, and size in bytes.

Collapse -

How can I get a file's attributes?

Poster rated this answer

Collapse -

How can I get a file's attributes?

by fenaikh In reply to How can I get a file's at ...

Hi
Well come to down sizing i left the mainframe about 10 years. I missed it not to many problems. Back to you qustion.It is an old one but may help.

pls read this MS Article.

Good luck

Examples of Loading MS-DOS Directory Listing into anArray

http://support.microsoft.com/support/kb/articles/Q41/4/47.ASP

good luck

Mohamed

Collapse -

How can I get a file's attributes?

by fenaikh In reply to How can I get a file's at ...
Collapse -

How can I get a file's attributes?

Poster rated this answer

Collapse -

How can I get a file's attributes?

by sl-campbell In reply to How can I get a file's at ...

If you are starting the program from a VB program then you can check the file properties of the files that that prg will use by using API calls, or by using the FileSystemObject:

Under Project|References select the 'Microsoft Scripting Runtime'
Then, in code:

Dim fso As FileSystemObject
Dim f As File
Set f = fso.GetFile("MyPath\MyFile")

then you can check certain properties like:

f.Attributes
f.DateCreated
f.DateLastAccessed
f.DateLastModified
f.ShortName
f.Type
f.Size

Collapse -

How can I get a file's attributes?

by sl-campbell In reply to How can I get a file's at ...

CORRECTION:

Needs to be declared As New

Dim fso As New FileSystemObject

Collapse -

How can I get a file's attributes?

Thanks. You're a life saver.

Collapse -

How can I get a file's attributes?

This question was closed by the author

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums