473,505 Members | 13,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSize - HowTo

I get a list of filenames from a directory with the following code, but
I can not work out how to get the filesize of the filename I have just
found.

I guess it is fileinfo.length, but I can not see how to turn my
filename(string) into a statement which would give me the filesize -
the brain is very slow today. Any help gratefully appreciated.

Dim files() As String = System.IO.Directory.GetFiles(root,
patt)
dim filename as string
Dim f As String
For Each f In files
filename = System.IO.Path.GetFileName(f)
DropDownList1.Items.Add(filename)
..... GET FILESIZE OF ABOVE FILE and add to array
filesizes
Next

Jun 29 '06 #1
3 4363
Hi Mosscliffe

Try this

for each f in files
dim fi as new FileInfo(f)
dim FileSize as int

FileSize = fi.Length()
next

Regards
Ray

mosscliffe wrote:
I get a list of filenames from a directory with the following code, but
I can not work out how to get the filesize of the filename I have just
found.

I guess it is fileinfo.length, but I can not see how to turn my
filename(string) into a statement which would give me the filesize -
the brain is very slow today. Any help gratefully appreciated.

Dim files() As String = System.IO.Directory.GetFiles(root,
patt)
dim filename as string
Dim f As String
For Each f In files
filename = System.IO.Path.GetFileName(f)
DropDownList1.Items.Add(filename)
..... GET FILESIZE OF ABOVE FILE and add to array
filesizes
Next

Jun 29 '06 #2
Use System.IO.FileInfo.Length.

http://msdn2.microsoft.com/en-us/lib...fo.length.aspx

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"mosscliffe" <pa***********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I get a list of filenames from a directory with the following code, but
I can not work out how to get the filesize of the filename I have just
found.

I guess it is fileinfo.length, but I can not see how to turn my
filename(string) into a statement which would give me the filesize -
the brain is very slow today. Any help gratefully appreciated.

Dim files() As String = System.IO.Directory.GetFiles(root,
patt)
dim filename as string
Dim f As String
For Each f In files
filename = System.IO.Path.GetFileName(f)
DropDownList1.Items.Add(filename)
..... GET FILESIZE OF ABOVE FILE and add to array
filesizes
Next

Jun 29 '06 #3
Thank you very much - all now working as envisaged. Just could not
figure it out.

Ray Booysen wrote:
Hi Mosscliffe

Try this

for each f in files
dim fi as new FileInfo(f)
dim FileSize as int

FileSize = fi.Length()
next

Regards
Ray

mosscliffe wrote:
I get a list of filenames from a directory with the following code, but
I can not work out how to get the filesize of the filename I have just
found.

I guess it is fileinfo.length, but I can not see how to turn my
filename(string) into a statement which would give me the filesize -
the brain is very slow today. Any help gratefully appreciated.

Dim files() As String = System.IO.Directory.GetFiles(root,
patt)
dim filename as string
Dim f As String
For Each f In files
filename = System.IO.Path.GetFileName(f)
DropDownList1.Items.Add(filename)
..... GET FILESIZE OF ABOVE FILE and add to array
filesizes
Next


Jun 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2227
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
6
3286
by: John | last post by:
Hi all, I'd like to evaluate dynamicaly the size of a dynamic file. I use the filesize() function... this is my code : $my_size =...
4
2602
by: Marek Möhling | last post by:
My server (Apache/1.3.28 - PHP/4.3.3) is configured to receive gzipped data via: Header append Accept-Encoding "gzip, deflate" PHP is configured to send gzipped data via: php_value...
2
11685
by: IWP506 | last post by:
I just CANNOT figure out what is wrong with this! ------ $op1f = fopen("./test.txt","r"); $op1 = fread($op1f, filesize($op1f)); ------
4
2857
by: Josef Sachs | last post by:
Is Andrew Kuchling's regex-to-re HOWTO available anywhere? I've found the following (dead) links on various Web pages: http://py-howto.sourceforge.net/regex-to-re/regex-to-re.html...
4
5450
by: Ken | last post by:
I would like to measure the fileSize of the image (without uploading it - php). I use: var size_pic = document.getElementById('num1').childNodes.fileSize; alert("size = " + size_pic); which...
3
3380
by: Arjen | last post by:
Hello, When I have read a file with x.xxx.xxx.xxx bytes it is sometimes handy to show it in an diverent format than bytes. Is there a handy way to do this? Or is there a function for it? ...
4
5298
by: Leon Friesema | last post by:
Howto get the filesize from a file on "the web" using the 2005 WebClient? TIA, Leon
2
4648
by: Eric Layman | last post by:
I have checked this setting in my php.ini allow_url_fopen = On It is ON be default. According to the PHP documentation: it stated that as of php5, filesize supports the reading of remote...
0
7213
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
7098
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...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4698
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
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
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 ...
0
406
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.