|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File locking problemtimer that goes off every second. It looks at a list of files on a source and then on a destination folder. If it can't find a file in the source folder in the destination folder, it copies it into the destination. Everything is working fine, except for one thing... There is another application that creates the files in the source folder. This application creates a file in the source folder, then it fills the file with data... The application that creates the file locks up until the copy application is closed.. I've tried setting the timer to every 30 seconds, but it still locks up. Is there a way to check to see if a file is in use first and then just skip that file? Here is some code that I use: SourceFiles = System.IO.Directory.GetFiles(txtSource.Text) DestFiles = System.IO.Directory.GetFiles(txtDestination.Text) Dim iCount As Integer For iCount = 0 To SourceFiles.Length - 1 bFound = False Dim iCountDest As Integer For iCountDest = 0 To DestFiles.Length - 1 If System.IO.Path.GetFileName(DestFiles(iCountDest)) = System.IO.Path.GetFileName(SourceFiles(iCount)) Then bFound = True Next If bFound = False Then sourcePath = SourceFiles(iCount) destPath = txtDestination.Text & "\" & System.IO.Path.GetFileName(SourceFiles(iCount)) System.IO.File.Copy(sourcePath, destPath) End If Next Thanks, Aaron -- --- Aaron Smith Remove -1- to E-Mail me. Spam Sucks. Look into the FileSystemWatcher instead of the timer. It is made to fix
problems like this. Show quoteHide quote "Aaron Smith" <thespirit***@smithcentral.net> wrote in message news:Mzb3e.13379$ZB6.7510@newssvr19.news.prodigy.com... >I have a small application that runs in the taskbar. All it has is a > timer that goes off every second. It looks at a list of files on a > source and then on a destination folder. If it can't find a file in the > source folder in the destination folder, it copies it into the > destination. Everything is working fine, except for one thing... There > is another application that creates the files in the source folder. > This application creates a file in the source folder, then it fills the > file with data... > > The application that creates the file locks up until the copy > application is closed.. I've tried setting the timer to every 30 > seconds, but it still locks up. > > Is there a way to check to see if a file is in use first and then just > skip that file? > > Here is some code that I use: > > SourceFiles = System.IO.Directory.GetFiles(txtSource.Text) > DestFiles = System.IO.Directory.GetFiles(txtDestination.Text) > Dim iCount As Integer > For iCount = 0 To SourceFiles.Length - 1 > bFound = False > Dim iCountDest As Integer > For iCountDest = 0 To DestFiles.Length - 1 > If System.IO.Path.GetFileName(DestFiles(iCountDest)) = > System.IO.Path.GetFileName(SourceFiles(iCount)) Then bFound = True > Next > If bFound = False Then > sourcePath = SourceFiles(iCount) > destPath = txtDestination.Text & "\" & > System.IO.Path.GetFileName(SourceFiles(iCount)) > > System.IO.File.Copy(sourcePath, destPath) > End If > Next > > Thanks, > Aaron > -- > --- > Aaron Smith > Remove -1- to E-Mail me. Spam Sucks. Ok, thanks.. I will look into that..
Aaron Ray Cassick (Home) wrote: Show quoteHide quote > Look into the FileSystemWatcher instead of the timer. It is made to fix > problems like this. > > "Aaron Smith" <thespirit***@smithcentral.net> wrote in message > news:Mzb3e.13379$ZB6.7510@newssvr19.news.prodigy.com... > >>I have a small application that runs in the taskbar. All it has is a >>timer that goes off every second. It looks at a list of files on a >>source and then on a destination folder. If it can't find a file in the >>source folder in the destination folder, it copies it into the >>destination. Everything is working fine, except for one thing... There >>is another application that creates the files in the source folder. >>This application creates a file in the source folder, then it fills the >>file with data... >> >>The application that creates the file locks up until the copy >>application is closed.. I've tried setting the timer to every 30 >>seconds, but it still locks up. >> >>Is there a way to check to see if a file is in use first and then just >>skip that file? >> >>Here is some code that I use: >> >> SourceFiles = System.IO.Directory.GetFiles(txtSource.Text) >> DestFiles = System.IO.Directory.GetFiles(txtDestination.Text) >> Dim iCount As Integer >> For iCount = 0 To SourceFiles.Length - 1 >> bFound = False >> Dim iCountDest As Integer >> For iCountDest = 0 To DestFiles.Length - 1 >> If System.IO.Path.GetFileName(DestFiles(iCountDest)) = >>System.IO.Path.GetFileName(SourceFiles(iCount)) Then bFound = True >> Next >> If bFound = False Then >> sourcePath = SourceFiles(iCount) >> destPath = txtDestination.Text & "\" & >>System.IO.Path.GetFileName(SourceFiles(iCount)) >> >> System.IO.File.Copy(sourcePath, destPath) >> End If >> Next >> >>Thanks, >>Aaron >>-- >>--- >>Aaron Smith >>Remove -1- to E-Mail me. Spam Sucks. > > > -- --- Aaron Smith Remove -1- to E-Mail me. Spam Sucks.
Hashtable question
Simple LookupAccountName (working) guidelines for developing an application How do you protect from pirating? SQL Error Object variable or With block variable not set. How can I get the following functionatilty in Windows Forms ? Anyone know what could cause the following error messages? Avoiding late binding Print information when ANY control is used |
|||||||||||||||||||||||