Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified
Preventing VB from using a file being modified Preventing VB from using a file being modified
Preventing VB from using a file being modified
Go Back  Xtreme Visual Basic Talk > > > Preventing VB from using a file being modified


Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2011, 04:49 PM
jsteinm1 jsteinm1 is offline
Newcomer
 
Join Date: Nov 2011
Posts: 3
Default Preventing VB from using a file being modified


First off, this is my first VB program I have ever developed. I am somewhat familiar with VBA.

I am writing a program to automatically recognize new data log files in a specific folder and proceed to process them in a routine I scripted. I have the program working fine for when I manually place files in there, but I know there will be an issue when my data logger is working because it will create files and then write to them for approximately 12 hours. The script I am using now to see new files is:

Code:
    Private Sub FileMonitor()
        watchfolder = New System.IO.FileSystemWatcher
        watchfolder.Path = CurDir() & "\Raw Data Logs"
        watchfolder.Filter = "*(Float).DAT"
        watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName
        AddHandler watchfolder.Created, AddressOf logchange
        watchfolder.EnableRaisingEvents = True
    End Sub
Which works fine, but how can I modify that or what should I use to force the program to wait until the file is done being modified? Say force it to wait at least 1 minute after the last modification? Thanks!


Side note: If anyone has any good VB book suggestions, I will likely buy one soon!
Reply With Quote
  #2  
Old 11-04-2011, 04:34 PM
jsteinm1 jsteinm1 is offline
Newcomer
 
Join Date: Nov 2011
Posts: 3
Default

I was able to figure out a work around for this using the code:

Code:
        'Checks for modification of file after creation
        If DateDiff(DateInterval.Minute, File.GetCreationTime(e.FullPath), File.GetLastWriteTime(e.FullPath)) >= 1 Then
            StartProcess = True
        Else
            Exit Sub
        End If
Its probably not the best, but it works for my situation because the file logger creates the file and then writes to the file when its finished without any intermediate writes.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified Preventing VB from using a file being modified
Preventing VB from using a file being modified
Preventing VB from using a file being modified
 
Preventing VB from using a file being modified
Preventing VB from using a file being modified
 
-->