Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,836 members, 7,802,677 topics. Date: Friday, 19 April 2024 at 06:39 PM

File Copy Monitoring Using Vb.net - Pls Help - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / File Copy Monitoring Using Vb.net - Pls Help (3414 Views)

I Need A Help To Write A Simple Login Form Using Vb.net / Vb.net Crystal Report & Dataset / Post Ur Vb 6.0 Questions Here (2) (3) (4)

(1) (Reply) (Go Down)

File Copy Monitoring Using Vb.net - Pls Help by nairalady(f): 6:21pm On Jul 27, 2012
pls i need a simple vb.net code that monitors file copy to external drive..

1 Like

Re: File Copy Monitoring Using Vb.net - Pls Help by lordZOUGA(m): 6:37pm On Jul 27, 2012
you mean like a progress bar?
Re: File Copy Monitoring Using Vb.net - Pls Help by nairalady(f): 7:21pm On Jul 27, 2012
No. When a file, eg. "me.jpg" is copied to an external device like USB or CD, the program should be able to record it on a text file or access db.
Re: File Copy Monitoring Using Vb.net - Pls Help by nairalady(f): 7:51pm On Jul 29, 2012
Pls i still need ur help
Re: File Copy Monitoring Using Vb.net - Pls Help by kadeerna: 9:50pm On Jul 29, 2012
The following code is for a console application that watches a specified folder e.g "C:\Test", or even "C:\" for creation of new files and writing the info to the Console. Run the application, type 'f' and hit enter at the "Enter a command (f, x)" prompt. Entering 'x' closes the application. Select a folder using the dialog that appears and click OK. The selected folder is echoed to the Console window. Copy and paste a file into the folder selected from the dialog and the pasted file name is written to the Console. Converting this to the a windows form application and/or logging the copy operation to a file or db is a trivial process.

Using the FileSystemWatcher has its limitations. For one, tiny file copy operations notifications could quickly fill up the FileSystemWatcher buffer causing notifications to be lost. Read on StackOverflow and around on the web on increasing the buffer size and other effective methods of watching the file system for ex. coding a file system filter driver.


Imports System.Windows.Forms
Imports System.IO
Imports System.Security.Permissions

Module Module1

Private _folderToWatch As String

<PermissionSet(SecurityAction.Demand, Name:="FullTrust"wink>
Sub Main()

Dim command As Char
Dim exitCase As Boolean = False

While (True And Not exitCase)
Console.WriteLine("Enter a command (f, x)"wink
command = Console.ReadLine()

Select Case command
Case "f"
SelectFolder()
Console.WriteLine("Watching: " & _folderToWatch)

Dim watcher As New FileSystemWatcher()
watcher.Path = _folderToWatch
watcher.IncludeSubdirectories = True

watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or
NotifyFilters.FileName Or NotifyFilters.DirectoryName Or
NotifyFilters.CreationTime)

AddHandler watcher.Created, AddressOf OnCreated

watcher.EnableRaisingEvents = True

Case "x"
exitCase = True

End Select
End While

End Sub

Private Sub OnCreated(ByVal sender As Object, ByVal e As FileSystemEventArgs)
Console.WriteLine("File: " & e.FullPath & " " & e.ChangeType)
End Sub

Public Sub SelectFolder()
Dim dialog As New FolderBrowserDialog()

With dialog
.RootFolder = Environment.SpecialFolder.Desktop
.SelectedPath = "C:\"
.Description = "Select the directory to watch"
If .ShowDialog = DialogResult.OK Then
_folderToWatch = .SelectedPath
End If
End With
End Sub

End Module
Re: File Copy Monitoring Using Vb.net - Pls Help by nairalady(f): 7:48pm On Jul 30, 2012
^Thanks. I appreciate. More suggestions pls
Re: File Copy Monitoring Using Vb.net - Pls Help by lordZOUGA(m): 5:37am On Jul 31, 2012
that is probably the only way.. Unless you want to move the files from inside software that does the monitoring
Re: File Copy Monitoring Using Vb.net - Pls Help by StarrMatthieu: 7:53am On Jul 31, 2012
I like this.
Re: File Copy Monitoring Using Vb.net - Pls Help by lordZOUGA(m): 11:09am On Jul 31, 2012
OR
(I don't do VB but this method can work only if it is possible to get the drive the "copy file" program is working on)
you can do if drive != "C"or "D" register the name of the file that is being copied...

(1) (Reply)

How Do I Pay For Apps On Google Play Store / Hiding Php Source Code! Any Ideas? / Need For More Programmers In Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.