mostafa122050
Forensic Analyst
LEVEL 1
300 XP
In this tutorial, we will create a program that can get the exact length of any kinds of file using the LOF function and without importing the system.IO.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only two Buttons named Button1 and labeled it as "Open a File" and Button2 labeled as "Get Length of the File". Insert an OpenFileDialog named OpenFileDialog1 for opening any types of file. Add also a textbox named TextBox1 for displaying the filename after browsing with the OpenFileDialog. You must design your interface like this:
3. For button1_click as Open File button, put this code below.
We have used an OpenFileDialog in showing and browsing a desired file to open. This will locate all types of files in your computer. Then after that, the desired file you have chose (the filename) is displayed in TextBox1.
4. For button2_click as Get Length of File button, put this code below.
Initialized variable length as long integer
Open a file in your desired file path and file name inputted in TextBox1
FileOpen(
1
, TextBox1.
Text
, OpenMode.
Input
)
Get length of file. This will return the size of the file in Bytes using the LOF Function
length =
LOF
(
1
)
Display the Length of the File in MessageBox
MsgBox
(
"The length of the file is: "
&
length &
" bytes"
)
Close the file
FileClose(
1
)
Output:
Download the source code below and try it! :)
For more inquiries just contact my number or e-mail below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09102918563
Telephone: 826-9296
E-mail:[email protected]
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Download
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only two Buttons named Button1 and labeled it as "Open a File" and Button2 labeled as "Get Length of the File". Insert an OpenFileDialog named OpenFileDialog1 for opening any types of file. Add also a textbox named TextBox1 for displaying the filename after browsing with the OpenFileDialog. You must design your interface like this:

3. For button1_click as Open File button, put this code below.
- Private
Sub
Button1_Click(
ByVal
sender As
System.
Object
, ByVal
e As
System.
EventArgs
)
Handles
Button1.
Click
- OpenFileDialog1.
ShowDialog
(
)
- TextBox1.
Text
=
OpenFileDialog1.
FileName
- End
Sub
We have used an OpenFileDialog in showing and browsing a desired file to open. This will locate all types of files in your computer. Then after that, the desired file you have chose (the filename) is displayed in TextBox1.
4. For button2_click as Get Length of File button, put this code below.
Initialized variable length as long integer
- Dim
length As
Long
Open a file in your desired file path and file name inputted in TextBox1
FileOpen(
1
, TextBox1.
Text
, OpenMode.
Input
)
Get length of file. This will return the size of the file in Bytes using the LOF Function
length =
LOF
(
1
)
Display the Length of the File in MessageBox
MsgBox
(
"The length of the file is: "
&
length &
" bytes"
)
Close the file
FileClose(
1
)
Output:

Download the source code below and try it! :)
For more inquiries just contact my number or e-mail below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09102918563
Telephone: 826-9296
E-mail:[email protected]
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Download
You must upgrade your account or reply in the thread to view hidden text.