473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining Size of a File

In VB.NET I find the IO object very handy in replacing most of the
functionality of the FileSystemObjec t. One exception, however, is in
determining the size of a file. How can you determine the size of a file in
VB.NET without adding the FileSystemObjec t to your project?
Jul 21 '05 #1
2 2232
The FileInfo class has a Length property.

Chris
"Phil Galey" <pa*****@starca lif.com.nospam> wrote in message
news:eG******** *****@tk2msftng p13.phx.gbl...
In VB.NET I find the IO object very handy in replacing most of the
functionality of the FileSystemObjec t. One exception, however, is in
determining the size of a file. How can you determine the size of a file in VB.NET without adding the FileSystemObjec t to your project?

Jul 21 '05 #2
Imports System.IO
....

Dim fi As New FileInfo(somepa th)

Then get the information from the FileInfo object. In keeping with the
abstraction-of-the-month buzz, the property you want is "Length", not
"Size".
--
Klaus H. Probst, MVP
http://www.vbbox.com/


"Phil Galey" <pa*****@starca lif.com.nospam> wrote in message
news:eG******** *****@tk2msftng p13.phx.gbl...
In VB.NET I find the IO object very handy in replacing most of the
functionality of the FileSystemObjec t. One exception, however, is in
determining the size of a file. How can you determine the size of a file in VB.NET without adding the FileSystemObjec t to your project?

Jul 21 '05 #3

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

Similar topics

2
5412
by: Luca | last post by:
I have the following problem: I'm developing a system where there are some processes that communicate each other via message queues; the message one process can send to another process is as follows: ****************************************** struct ST_MSG { int iType; char aData; }
12
7859
by: Raja | last post by:
How to know the buffer size and increase buffer size in c++.
2
7875
by: Phil Galey | last post by:
Using the following, you can determine the size of a file: Dim fi As New IO.FileInfo(<Path to file>) MsgBox(fi.Length) .... but what about the size of a directory? The IO.DirectoryInfo object doesn't have a Length property. In is there a way in VB.NET to determine the size of a directory without having to resort to importing the...
2
468
by: Phil Galey | last post by:
In VB.NET I find the IO object very handy in replacing most of the functionality of the FileSystemObject. One exception, however, is in determining the size of a file. How can you determine the size of a file in VB.NET without adding the FileSystemObject to your project?
14
2735
by: googler | last post by:
Is there any C library function that returns the size of a given file? Otherwise, is there a way in which file size can be determined in a C program? I need to get this for both Linux and Windows platforms, so a generic solution is what I am looking for. Thanks for your help.
2
1545
by: Doug | last post by:
Hi, It looks like the only way to get a size of a file within dot net is to use FileInfo and the Length property. However that only returns the number of bytes in the file which is translating properly (I have a file that has a size of 1 KB but has 14 bytes in it so the conversion isn't working right). Is there some method/property out...
9
3834
by: vineeth | last post by:
Hello all, I have come across a weird problem, I need to determine the amount of bytes read from a file, but couldn't figure it out , My program does this : __ file = open("somefile") data = file.read() print "bytes read ", len(data) ---
13
10582
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to process the file. The appearance of the command file triggers the device to grab the original file. My problem is I don't want to write the command file...
0
177
by: Cameron Simpson | last post by:
On 10Jul2008 13:20, Manuel Vazquez Acosta <mva.led@gmail.comwrote: | Cameron Simpson wrote: | On 09Jul2008 15:54, Ethan Furman <ethan@stoneleaf.uswrote: | >The solution my team has used is to monitor the file size. If the file | >has stopped growing for x amount of time (we use 45 seconds) the file is | >done copying. Not elegant, but it...
0
7499
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3490
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1919
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 we have to send another system

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.