-
May 4th, 2008, 10:54 PM
#1
Thread Starter
PowerPoster
[2005] Progress bar doesnt increment or get an error
I am using my encryption class from MSDN which has worked so far until this point. The code is below and I either get an error where the DecodeText() part is right now or if I put it in the other areas for the file name, I get no errors but the progress bar doesn't move (line 5 or line 27). Any ideas?
vb Code:
Imports Cryptography.clsCrypto
Public Class frmSQLExecuteProgress
'specify the location of the dbu file
Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'form layout
FormLayout(Me)
'start the timer
With tmrProgBar
.Enabled = True
.Interval = 7000
.Start()
End With
End Sub
Private Sub cmdDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDone.Click
'when the done button is clicked on, close the form
Me.Close()
End Sub
Private Sub tmrProgBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrProgBar.Tick
With (My.Computer.FileSystem)
'lets see if the file exists
If System.IO.File.Exists(strFileLocation) Then
'read all the lines in the file
Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
With prgDatabaseExecution
'set the minimum to 0%
.Minimum = 0
'set the maximum to 100%
.Maximum = 100
'give step the value of the number of lines in the dbu file
.Step = CInt(arrDBULineCount.Length.ToString)
'get the incremental by dividing the line count by 100
.Value = CInt(.Step / .Maximum)
'start the progress bar
.PerformStep()
If .Value = 100 Then
'now that the request has been completed, delete the file
IO.File.Delete(strFileLocation)
With tmrProgBar
.Stop()
.Enabled = False
'resize the form
With Me
.Height = 110
.Width = 300
End With
'show the done button
cmdDone.Visible = True
End With
End If
End With
End If
End With
End Sub
End Class
error is
An unhandled error has occurred in the application and the error log is attached for resolution assignment.
Message:
Illegal characters in path.
Stack trace:
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding)
at System.IO.File.ReadAllLines(String path, Encoding encoding)
at System.IO.File.ReadAllLines(String path)
at BusinessStudio.frmSQLExecuteProgress.tmrProgBar_Tick(Object sender, EventArgs e) in D:\BusinessStudio\frmSQLExecuteProgress.vb:line 29
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
-
May 4th, 2008, 11:07 PM
#2
Re: [2005] Progress bar doesnt increment or get an error
I would suggest that this line:
vb.net Code:
Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
is quite wrong. Presumably DecodeText opens the file, reads the contents, decrypts it and returns the result. ReadAllLines expects a file path and, if my assumption is correct then what you're passing to it is definitely not a file path.
As for the ProgressBar "not working" you probably have to call its Refresh method to force it to repaint because your thread is too busy working to update the UI.
-
May 5th, 2008, 12:57 AM
#3
Frenzied Member
Re: [2005] Progress bar doesnt increment or get an error
I've found Application.DoEvents() does the trick for me (showing progress bar progress).
Cheers
Icyculyr
-
May 5th, 2008, 09:59 PM
#4
Thread Starter
PowerPoster
Re: [2005] Progress bar doesnt increment or get an error
Originally Posted by jmcilhinney
I would suggest that this line:
vb.net Code:
Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
is quite wrong. Presumably DecodeText opens the file, reads the contents, decrypts it and returns the result. ReadAllLines expects a file path and, if my assumption is correct then what you're passing to it is definitely not a file path.
As for the ProgressBar "not working" you probably have to call its Refresh method to force it to repaint because your thread is too busy working to update the UI.
ive tried using the .refresh and the progress bar still isnt incrementing. also tried application.doevents and still doesnt do anything so far. still trying to debug this thing. thanks for the suggestions.
-
May 5th, 2008, 10:04 PM
#5
Thread Starter
PowerPoster
Re: [2005] Progress bar doesnt increment or get an error
i even did a messagebox and the text file is being decrypted as the content of the file views in the messagebox. only thing is, its not getting the lines of code in teh decrypted file and then incrementing the progressbar. hm.
vb Code:
Imports Cryptography.clsCrypto
Public Class frmSQLExecuteProgress
'specify the location of the dbu file
Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'form layout
FormLayout(Me)
'decode the text content
DecodeText(strFileLocation)
MessageBox.Show(DecodeText(strFileLocation))
'start the timer
With tmrProgBar
.Enabled = True
.Interval = 7000
.Start()
End With
End Sub
Private Sub cmdDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDone.Click
'when the done button is clicked on, close the form
Me.Close()
End Sub
Private Sub tmrProgBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrProgBar.Tick
With (My.Computer.FileSystem)
'lets see if the file exists
If System.IO.File.Exists(strFileLocation) Then
'read all the lines in the file
Dim arrDBULineCount() As String = IO.File.ReadAllLines(strFileLocation)
With prgDatabaseExecution
'set the minimum to 0%
.Minimum = 0
'set the maximum to 100%
.Maximum = 100
'give step the value of the number of lines in the dbu file
.Step = CInt(arrDBULineCount.Length.ToString)
'get the incremental by dividing the line count by 100
.Value = CInt(.Step / .Maximum)
'start the progress bar
.PerformStep()
'refresh the progress bar
'.Refresh()
Application.DoEvents()
If .Value = 100 Then
'now that the request has been completed, delete the file
IO.File.Delete(strFileLocation)
With tmrProgBar
.Stop()
.Enabled = False
'resize the form
With Me
.Height = 110
.Width = 300
End With
'show the done button
cmdDone.Visible = True
End With
End If
End With
End If
End With
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|