Size of File

J

Jarod_24

I got a Log-Class that writes to a file named "Event.Log"
But i need a way to determine when the file is larger than 1 Mb.

When the file is => than 1 Mb, i'll rename it to "Event.old" and create a
new file called "Event.log".

I tried with the following but it didn't work:

Dim oFile As IO.FileStream
Dim maxsize As Long = 1048576 '1 MB in bytes

'Code...

If oFile.Length >= maxsize Then 'Only allows files up to 1Mb in size
'Closing, Renaming & Creating new File...
End If
 
H

Herfried K. Wagner [MVP]

* "Jarod_24 said:
I got a Log-Class that writes to a file named "Event.Log"
But i need a way to determine when the file is larger than 1 Mb.

When the file is => than 1 Mb, i'll rename it to "Event.old" and create a
new file called "Event.log".

I tried with the following but it didn't work:

Dim oFile As IO.FileStream
Dim maxsize As Long = 1048576 '1 MB in bytes

Use 'FileLen' to get the length of a file in bytes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top