Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding byte info for files and folders
Hey guys
How do I find the byte info for files and folders? The reason I want to do this is because i have a directory C:\test Files in this directory can be added and/or changed. How would I check the size of that directory? Also how would I check the size of a file called "ABC.xls" in that same directory? Thanks Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding byte info for files and folders
vba.FileLen(strPath) gives length in bytes the prefix VBA is optional but included for clarity. FirstMethod EXCLUDES the subdirs (pure VBA) Second INCLUDES the subdirs (latebound Scripting Runtime) Both return bytes. for KB : result \ 1024 for MB : result \ 1024 ^ 2 Function DirSize&(Optional sDir$, Optional sMask$ = "*.*") Dim n&, sFile$ If sDir = vbNullString Then sDir = VBA.CurDir$ End If If VBA.Right$(sDir, 1) < Application.PathSeparator Then sDir = sDir & Application.PathSeparator End If sFile = VBA.Dir$(sDir & sMask) While sFile < vbNullString n = n + VBA.FileLen(sFile) sFile = VBA.Dir$() Wend DirSize = n End Function Function DirSizeFS&(Optional sDir$) 'INCLUDES SUBFOLDERSIZE 'http://msdn.microsoft.com/library/en-us/script56/html/jsprosize.asp If sDir = vbNullString Then sDir = VBA.CurDir$ End If With CreateObject("scripting.filesystemobject") If .FolderExists(sDir) Then DirSizeFS = .GetFolder(sDir).Size End If End With End Function keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Todd Huttenstine" wrote: Hey guys How do I find the byte info for files and folders? The reason I want to do this is because i have a directory C:\test Files in this directory can be added and/or changed. How would I check the size of that directory? Also how would I check the size of a file called "ABC.xls" in that same directory? Thanks Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel files saved to H drive are 0 byte size on initial save | Setting up and Configuration of Excel | |||
Users periodically get 0 byte size files on initial save to networ | Excel Discussion (Misc queries) | |||
Display of Double byte chars in CSV files | Excel Discussion (Misc queries) | |||
links to same files in different folders | Excel Worksheet Functions | |||
Finding Folders | Excel Programming |