By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

File size

P: n/a
Hello,

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

Thank you.

Catalin
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
In article <#c**************@TK2MSFTNGP11.phx.gbl>,
ca**************@midwestern.net says...
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.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2

P: n/a
"Catalin Porancea" <ca**************@midwestern.net> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
Cor
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,

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

Nov 20 '05 #4

P: n/a
Thanks guys. Could somebody explain me how to read the file and get the
number of lines?

Thank you.
"Catalin Porancea" <ca**************@midwestern.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello,

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

Thank you.

Catalin

Nov 20 '05 #5

P: n/a
"Catalin Porancea" <ca**************@midwestern.net> schrieb
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".
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

P: n/a
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" <ca**************@midwestern.net> wrote in message
news:uK**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. Could somebody explain me how to read the file and get the
number of lines?

Thank you.
"Catalin Porancea" <ca**************@midwestern.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello,

How can I get the file size in KB and the number of lines the file

contains
in VB .Net?

Thank you.

Catalin


Nov 20 '05 #7

P: n/a
* "Catalin Porancea" <ca**************@midwestern.net> scripsit:
Thanks guys. Could somebody explain me how to read the file and get the
number of lines?


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

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.