?
Solved

Accessing Properties of a file

Posted on 2003-03-13
10
Medium Priority
?
545 Views
Last Modified: 2013-11-23
I need to access the properties of a file.

You know when right-clicking a file and go to Properties, It displays a bwindow with all the file's properties.

I need to access that.

Please help, Examples will be a apreciated.

Chemical X
0
Comment
Question by:Chemical_x
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 2

Expert Comment

by:uncle_med
ID: 8126564

FileLen(sPathtoFile) returns the size of the file

FileDateTime(sPathtoFile) returns the date+Time of the file


0
 
LVL 14

Expert Comment

by:aelatik
ID: 8126571
Use API to gather File Info, dowload 'API GUIDE' from www.allapi.net ( its shipped with 900 API calls )

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20548023.html

0
 
LVL 4

Expert Comment

by:iozturk
ID: 8126587
Function ShowFolderSize(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(filespec)
   s = UCase(f.Name) & " uses " & f.size & " bytes."
   ShowFolderSize = s
End Function

If you add Microsoft Scripting Runtime from references, then you see shorcut helps when typing.

But there is a bug in size (altough microsoft does not confirm and says this was by desing) size properties larger than ~2GB gives wrong results. (such as file size and free space).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:uncle_med
ID: 8126608
Chemical

If you want to get even greater information on files, you can use the scripting object.


Check the following in the References menu
"Microsoft Scripting Runtime"

create a procedure and declare the following:
    Dim FSO As Scripting.FileSystemObject


type in FSO followed by a dot and you'll see a lot of methods and properties to access and manipulate files.

Hope it helps
0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8126766
Have also a look at GetAttr vb keyword
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 8126975
Try this

dim oFSO as new filesystemobject
dim oFile as file

set oFile = ofso.getfile("c:\test.txt")

Now place a watch on oFile and explore it ;)

Try to search for File-Object in your MSDN to find what all properties mean...

0
 

Accepted Solution

by:
NoCloneGroup earned 400 total points
ID: 8127807
To Display the File Properties Dialog Box
http://www.freevbcode.com/ShowCode.Asp?ID=445

To Search File and Get File Property Using API Classes
http://www.freevbcode.com/ShowCode.Asp?ID=2318
0
 

Expert Comment

by:CleanupPing
ID: 9056376
Chemical_x:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9692806
Moderator, my recommended disposition is:

    Accept NoCloneGroup's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question