TechnoTone Posted February 11, 2003 Posted February 11, 2003 I am trying to get the size of a file. I am using the Open method of the File class to get a FileStream object and using the Length property which is working fine when the file is accessible. However, most of the time the file will be open by another program. I've also tried to open the file using OpenRead and that still doesn't work. How can I get the size of a file without actually opening it? PS. The strange thing is that when I attempt to open a file that is in use by another pogram an exception doesn't occur. I just get nothing returned instead of a FileStream object. I would have thought an exception would be raised. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Gurus* divil Posted February 11, 2003 *Gurus* Posted February 11, 2003 Use the FileInfo class; Dim info As New FileInfo(path) Dim fileSize As Long = info.Length FileInfo info = new FileInfo(path); long fileSize = info.Length; Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
TechnoTone Posted February 11, 2003 Author Posted February 11, 2003 I figured it was something simple - I just couldn't find it in the help. Thanks. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.