Get file size
Get file size
Get file size
Get file size
Get file size
Get file size Get file size Get file size Get file size Get file size Get file size Get file size Get file size
Get file size Get file size
Get file size
Go Back  Xtreme Visual Basic Talk > > > Get file size


Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2014, 06:29 AM
Mike Mike is offline
Contributor
 
Join Date: Apr 2001
Location: Montreal, Canada
Posts: 462
Default 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!
Reply With Quote
  #2  
Old 03-08-2014, 08:37 AM
PlausiblyDamp's Avatar
PlausiblyDampGet file size PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

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?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 03-11-2014, 08:52 PM
Mike Mike is offline
Contributor
 
Join Date: Apr 2001
Location: Montreal, Canada
Posts: 462
Default

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!
Reply With Quote
  #4  
Old 03-12-2014, 03:48 AM
PlausiblyDamp's Avatar
PlausiblyDampGet file size PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I would carry on using FileInfo then, if it doesn't need disposing then it shouldn't be leaving resources open that need Disposing.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Get file size
Get file size
Get file size Get file size
Get file size
Get file size
Get file size Get file size Get file size Get file size Get file size Get file size Get file size
Get file size
Get file size
 
Get file size
Get file size
 
-->