Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jul 4th, 2007, 3:30 PM   #1
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Preventing Timeout Message During Long Processes

So currently I am working on a program to backup files. What it does is search through each directory recursively like so:
vbnet Syntax (Toggle Plain Text)
  1. Public Sub BackUp(ByVal root As String)
  2. Dim FoundFile, FoundDirectory As String
  3. 'Loop thru each of the files in this directory
  4. For Each FoundFile In My.Computer.FileSystem.GetFiles(root)
  5. If (IO.File.GetAttributes(FoundFile) = IO.FileAttributes.Archive) Or RootCreated Then
  6. ListBox1.Items.Add(FoundFile)
  7. ListBox1.Update()
  8. Dim FileName As String
  9. FileName = RemoveSource(FoundFile, Source)
  10. Try
  11. IO.File.Copy(FoundFile, Destination & FileName)
  12. Catch ex As Exception
  13. Dim DestFile As String = Destination & FileName
  14. Dim DestFileArr() As String = DestFile.Split("\")
  15. Dim l As Integer
  16. Dim folder As String
  17. folder = DestFileArr(0)
  18. For l = 1 To DestFileArr.GetUpperBound(0) - 1
  19. folder = folder & "\" & DestFileArr(l)
  20. If Not IO.Directory.Exists(folder) Then
  21. IO.Directory.CreateDirectory(folder)
  22. End If
  23. Next
  24. Try
  25. IO.File.Copy(FoundFile, Destination & FileName)
  26. Catch ex1 As Exception
  27. MsgBox("Error:" & Chr(13) & ex1.Message & Chr(13) & " No Folder for the file to be placed in")
  28. End Try
  29. End Try
  30. ' IO.File.SetAttributes(FoundFile, IO.FileAttributes.Normal)
  31. IO.File.SetCreationTime(Destination & FileName, IO.File.GetCreationTime(FoundFile))
  32. IO.File.SetLastAccessTime(Destination & FileName, IO.File.GetLastAccessTime(FoundFile))
  33. IO.File.SetAccessControl(Destination & FileName, IO.File.GetAccessControl(FoundFile))
  34. IO.File.SetLastWriteTime(Destination & FileName, IO.File.GetLastWriteTime(FoundFile))
  35. End If
  36. Next
  37. 'Loop thru each directory in this directory
  38. For Each FoundDirectory In My.Computer.FileSystem.GetDirectories(root)
  39. 'Give the user feedback about progress
  40. 'LabelSearch.Text = "Scanning: " & FoundDirectory
  41. 'LabelSearch.Update()
  42.  
  43. 'Recursively call this very same sub procedure!
  44. BackUp(FoundDirectory)
  45. Next
  46. End Sub
I have a problem after I hit about the 100th file, it "dies" and the compiler is like it's taking to long. It then asks me if I want to continue and I say yes. How do I stop that? I've tried GC.KeepAlive(me), for each file but that didn't seem to work. This is going to be used for directories that could possibly have over 100k files and I don't want to have to sit and hit yes every so many times.
PhilBon is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GOTO Sys. Tray Src. (code Snippet) Cipher Show Off Your Open Source Projects 1 Oct 17th, 2006 1:38 PM
Compiling Maverik 6.2 (from C) megamind5005 C 16 May 3rd, 2006 5:41 PM
visual basic pixel image comparison youngnoviceinneedofhelp Visual Basic 3 Mar 19th, 2006 1:57 PM
Jackpot game zorin Visual Basic 3 Jun 10th, 2005 1:19 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:41 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC