Please Help. Expression Expteted with ByVal Sub Call
I keep getting an Expression Expected Error in this first section with both the ByVal underlined. Im simply trying to call the Encrypt Sub... I am loosing my mind with this. I tryed just
Encrypt() but then I get errors about the System.IO.FileSystemEventArgs not being including in the call....
If anyone has some ideas please share.
VB Code:
Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
'Call the first encryption method with the error handler.
Encrypt(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs)
End Sub
Here is the Encrypt sub that I am trying to call. Everything here is fine.
VB Code:
Public Sub Encrypt(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs)
'Ignore the temp files that are being encrpyted.
If System.IO.Path.GetExtension(e.FullPath) = tempExt Then Exit Sub
Do
Try
'Encrypt the file that is being created.
EncryptFile(e.FullPath, pwBytes)
' Exit if successful
Exit Do
Catch ex As Exception
Dim attempts As Integer
attempts += 1
' Make up to 10 attempts.
If attempts > 10 Then Exit Sub
' Wait for a while and retry the operation.
System.Threading.Thread.Sleep(1000)
End Try
Loop
End Sub
12/32/84 - I need some code to make me a sandwhich.
Too many arguments to 'Public Sub Encrypt(e As System.IO.FileSystemEventArgs)'.
With e underlined..
Tryed just Encrypt(Sender) and it took it, but then I get a cast exeption when I click on the button. I'm at a loss. This is the only potion of the app tha is giving me problems.
12/32/84 - I need some code to make me a sandwhich.
Im getting the code from a Windows service that creates a Dir on your hd. Files that are copied into the folder get encypted.
I'm getting the original from a book (Programming Microsoft Visual Basic .NET)
Only parts of the code are from the book. I'm just making it a windows app rather then a service. So the idea is that when the user clicks on the btnEncrypt button the files in the folder would then be encrypted.. Atleast thats the idea. And it wont work!
12/32/84 - I need some code to make me a sandwhich.
Ok, I see. The encrypt function you are trying to call should be wired to an event. The function is looking for 2 objects. The sender is the object on which the event was raised, and e is the arguments from the objects.
Well, when the program starts it creates a dir - C:\Encrypt
and starts to watch to watch the dir for changes (FSW - FileSystemWatcher). So if a file gets copied into that folder it
automatically encrypts it. The problem is that the file(s) has to to be copied; I just havent found a way around this yet. So my plan is to open the dir when the user clicks: btnOpenDir.
At this point the user can just drag files they want encrypted into the folder and then click: btnEncrypt. Which is where I am having the problem.
The encryption process works like it should. As a matter of fact it works like I said by just copying files into the dir. But just not whith the click event.
So basically I am trying to stimulate the encrytion process with the click event for the files that are already in the dir.
Also when encrypted files are placed in, and the button pressed they get decrypted but thats not valid to the problem.
I hope that makes sense.
12/32/84 - I need some code to make me a sandwhich.
Either change
Public Sub Encrypt(ByVal e As System.IO.FileSystemEventArgs)
to
Public Sub Encrypt(ByVal o As System.Object, ByVal e As System.IO.FileSystemEventArgs)
or
Encrypt(o, e)
to
Encrypt(e)
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.