473,480 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

File size

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
7 5664
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
"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
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
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
"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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5426
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
4
2172
by: M P | last post by:
Can you help me find an asp code that will upload a file from my PC to web server? Mark
11
3050
by: Skc | last post by:
I have a .txt which has been exported as a .csv from an external source. What i need to do is to import this into SQL2000 (into a table) but I need to do special things on the data: 1. I need to...
0
3904
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
2743
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
2
2547
by: Dan | last post by:
Hi, I know this code is not entirely javascript, but bare with me. Can you please tell me why this does not work: page: filemanager.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
1
2562
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
3
3955
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
2
14501
by: cleary1981 | last post by:
Hi, I have created a script in PHP thats generates an SVG image. Want I want to do is have PHP save this as example.svg. Can this be done? Heres my code <?php require "config.php"; $proj_id =...
3
4399
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.