Dim time As Integer = Environment.TickCount
Do While (True)
If Environment.TickCount - time >= ms Then
Exit Do
End If
Loop
End Sub
Happy Coding!
I will show you how to watch file’s activities in a folder and log it, say if a text file is created, changed, deleted etc in specific folder that will be logged in separated text file
First Create a Folder of your own name in your specified path,
In D drive create a folder WatchFolder so the path would be D:\WatchFolder
In D drive create another folder Logs and inside the Log Folder Create Log.txt so the path would be like this D:\Logs\Log.txt
Now create a Project
File-> New Project -> WindowsApplication1 - OK!
In the left side toolbox pan drag and drop FileSystemWatcher control to the Form
Create Two Buttons Button1 and Button 2 in the Form
Change the Text of Button1 as Start Watch and Change the Text of Button2 as Stop Watch
And Write the Code as Follows
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FileSystemWatcher1.Path = "D:/WatchFolder"
MsgBox("Started Watching Folder")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
FileSystemWatcher1.Dispose()
MsgBox("Stopped Watching Folder")
End Sub
Private Sub FileSystemWatcher1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
WriteLog(e.Name + " Changed")
End Sub
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
WriteLog(e.Name + " Created")
End Sub
Private Sub FileSystemWatcher1_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Deleted
WriteLog(e.Name + " Deleted")
End Sub
Private Sub WriteLog(ByVal strMsg As String)
Dim fs As FileStream = New FileStream("D:\WatchFolder\Logs\Log.txt", FileMode.Append, FileAccess.Write)
Dim m_streamWriter As StreamWriter = New StreamWriter(fs)
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End)
m_streamWriter.WriteLine(Now.ToString() & " ::==> " & strMsg & Constants.vbLf)
m_streamWriter.Flush()
fs.Close()
fs.Dispose()
End Sub
End Class
Report generation Plays a Major Role in Application Project, So I will show you how create a simple report using Crystal Report XI
Say Table A --> Describes the student Details
Table A
Student Id (Primary Key)
Student Name
Student Class
Say Table B --> Describes the Student Fees Paid Details
Table B
Paid Id (Primary Key)
Student Id (Foreign Key)
Paid Amount
Paid Date
Table B will have multiple Entries for Single Entry of Table A
I will Explain Step by Step Method to display in the Crystal Report XI
If you preview, you can see the Table B Details of Every Record of Table A
And you can filter by record selection formula.
Happy To Share!
Close Project Coordination -We know who to blame.
Low Maintenance - Impossible to fix if broken.