Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET File I/O and Registry (http://www.xtremevbtalk.com/-net-file-i-o-and-registry/)
-   -   Get file size (http://www.xtremevbtalk.com/-net-file-i-o-and-registry/326902-file-size.html)

Mike 03-08-2014 06:29 AM

Get file size
 
Hi,

I'm currently using the following to get the size of a file:

Code:

Dim infoReader As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(TheFilePath)
lFileLength = CLng(infoReader.Length)
infoReader = Nothing

However, this procedure does not support IDisposable. Is there way of getting the filesize using something like FileStream or StreamReader instead which will support IDisposable?

Thanks!

PlausiblyDamp 03-08-2014 08:37 AM

It doesn't support IDisposable because there is nothing that needs Disposing in a FileInfo instance. Is there a reason you need support for IDisposable?

Mike 03-11-2014 08:52 PM

This is used in a service that runs 24/7/365 which runs this piece of code every 30 seconds so I really want to make sure that no tiny amount of resources is taken and not completely released back, that's all. Thanks!

PlausiblyDamp 03-12-2014 03:48 AM

I would carry on using FileInfo then, if it doesn't need disposing then it shouldn't be leaving resources open that need Disposing.


All times are GMT -6. The time now is 09:42 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.