Solved

Monitor Windows Directory

Posted on 2014-01-29
4
193 Views
Last Modified: 2014-01-30
Hello

I need a bit of advice,  I Have Windows server 2008r2 this runs an ftp service to our partner site. I would the server to email me when they put a file on the system. I have tried watch Dir which works but it cost $79 dollars. is there a better solution?  Could I set up a schedule  task to scan the directory for change? or if a file name has the name test in it?

regards,
0
Comment
Question by:jwc1972
  • 2
4 Comments
 
LVL 9

Expert Comment

by:p_sie
ID: 39820242
Hi!

Do you need to use VB Classic? If you can also use vb.net (express edition is free) then you can use the FileSystemWatcher control, which can monitor a certain directory for file changes.
You can even use the control in a service.

If you need to use VB Classic, then I think you have to write a function yourself that scans the directories for new files.

p_sie
0
 
LVL 32

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 250 total points
ID: 39820307
yes you could create a VB6 function, but you also need to read and update a database (of sorts, could be text file) , so that you know what has changed....

and to do that you will need to use the Scripting.FileSystem object or a windows API call to get the details of all the files currently in the folder.

Are you sure $79 wouldnt be well spent ?

or is the DateModified attribute of the file accurate enough to tell what has changed, in which case you only need to store the DateTime of last check.
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39820322
I no longer have VB6 on my system so this is just a guess.
Sub Test
'add reference to Scripting Runtime	
Dim fso As New FileSystemObject
	Dim fld As Folder
	Dim fil As File
	Set fld = fso.GetFolder("C:\Test")
        dim lastUpdate as Date
        'get lastUpdate from the ini file
        open "myIniFile.ini" for input as #1
           lineinput #1, lastdatetext
        close #1
        lastUpdate = datevalue(lastdatetext) + timevalue(lastdatetext)
        nowdatetext = format(now(),"dd-mmm-yyyy HH:nn:ss")
	For Each fil In fld.Files
  		if fil.DateLastModified > lastUpdate then 
		   AddFileToList fil.Path
                end if
	Next file
        open "myIniFile.ini" for output as #1
           writeline #1, nowdatetext
        close #1

Set fil = Nothing
Set fld = Nothing
Set fso = Nothing


End Sub

Sub AddFileToList(thefilename as string)

  'show the activity

End sub

Open in new window



http://bytes.com/topic/visual-basic/insights/697284-filesystemobject-model-how-list-files-directory-vb6
0
 
LVL 16

Accepted Solution

by:
AlexPace earned 250 total points
ID: 39820768
I agree with robberbaron on this one.  If you can solve the problem for $79 just do it.   Assuming you are a software industry professional that $79 is less than it costs your employer for one hour of your time.  I used to make that mistake all the time.... I think I justified it to myself by "saving money" but I think the truth of the matter is that I have a need to understand and solve problems and this was getting in the way of my rational thinking.  

Anyway, to put this post at least somewhere near the topic ... I would solve this problem with Robo-FTP and that costs $150.... but it was basically designed for FTP automation so you can do stuff like make an automatic retry loop for the file transfer and then have the Robo script itself send the email as soon as the remote server acknowledges successful transmission... fewer moving parts that way and the best part (at least for my employer) is that the software is supported by a 3rd party company so they are not dependant on me continuing to work for them.  YMMV.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Finding a job can be stressful - searches, resume tweaks, and networking events can be super boring. Luckily we're here to help you land your dream job!
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. Theā€¦
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now