how to






 

Question by  Anonymous

How do I find out the size of a file in vb6?

 
+7

Answer by  nimrod (321)

You need to create an object (say OBJn) ant then assign it the value of the function OBJn = CreateObject("Scripting.FileSystemObject") then you'll need another object to store the results of fileprop = OBJn.GetFolder("C:\WINDOWS") the object fileprop has a list of attributes, one of them is the size in bytes fileprop.Size

 
+5

Answer by  digital1007 (113)

Use this code: Private Sub Command1_Click() Dim MySize As Long If Dir$("c:\program files\myfile.txt") vbNullString Then MySize = FileLen("c:\program files\myfile.txt") Else MsgBox "file doesn't exist" End If End Sub

 
+5

Answer by  nuttree (1596)

If you create a FileSystemObject with the command: set fs = CreateObject("Scripting.FileSystemObject"), you can create a file with the command: set f=fs.GetFile(filename). Once you have a File object, you can query its properties, and one of these properties is Size. So iFileSize = f.Size would give you the file's size.

 
+5

Answer by  LordFury (35)

Hm you could use the GetFileInfo object of the FileInfO class. To do this you would need to return the info and store it in the IO object. Something like this Dim myFileInfo As System.Io.FileInfo myFileInfo = puter.FileSystem.GetFileInfo("C:\testfile.txt") MsgBox("The file " & myFileInfo.Length & " bytes.")

 
+4

Answer by  gigo (1706)

This can be done over the FileSystemObject. First instanciate it with CreateObject and define the path. Then use the Size property.

 
+3

Answer by  mansi (521)

To check file size in vb6 Code: Dim ret As Long ret = FileLen("c:\someFile.ext") If ret > 0 Then 'or simply "If ret Then" 'do your thing... End If 'or Dim ret As Boolean ret = FileLen("c:\someFile.ext") > 0 If ret = True Then '-||- 'do your thing... End If

 
You have 50 words left!