File size

  • Thread starter Thread starter Catalin Porancea
  • Start date Start date
C

Catalin Porancea

Hello,

How can I get the file size in KB and the number of lines the file contains
in VB .Net?

Thank you.

Catalin
 
Catalin Porancea said:
How can I get the file size in KB

Create a System.IO.FileInfo object. It's length property returns the size.

Or use Microsoft.VisualBasic.FileSystem.FileLen.
and the number of lines the file
contains in VB .Net?

You have to open the file and count the lines.
 
Hello,

How can I get the file size in KB and the number of lines the file contains
in VB .Net?

Size? FileInfo.Length

Number of lines? Nothing automatically. You'll have to code that
yourself.
 
Hi Catalin,

When it is a diskfile you can look for the fileinfo class

If it is a webfile you can look for httpwebrequest, httpwebresponse and the
webheadercollection.

But the numbers of lines will be a little bit difficult before reading.

I hope this helps

Cor
Hello,
 
Thanks guys. Could somebody explain me how to read the file and get the
number of lines?

Thank you.
 
Catalin Porancea said:
Thanks guys. Could somebody explain me how to read the file and get
the number of lines?

Have you already had a look at the VB.NET language tour? It is part of the
VB.NET language documentation. There is a sub topic "Processing drives,
folders and files". The chapter "Programming with .NET Framework" in the
Framework documentation also contains sub chapters grouped thematically.
There's one subject "Working with I/O".
 
Catalin, it really depends on how you are defining a line. There are many
different measures the most common of which is number of CarriageReturn or
Line Feeds. However, that's not an accurate measure for many industries, so
the number of characters divided by a set number of characters (for
instance, in Medical Transcription, it's common to have something like 65
characters equals a line). If it's the first, you CrLf's may not work b/c
of word wrap. However, one easy way to do it is to read the text in as a
String using a Stream Object, and then using a regex or counting routine to
count the number of line Breaks.
 
* "Catalin Porancea said:
Thanks guys. Could somebody explain me how to read the file and get the
number of lines?

'System.IO' namespace, 'StreamReader' class, 'ReadLine' method.
 
Back
Top