-
Nov 29th, 2014, 04:23 PM
#1
Thread Starter
Member
[RESOLVED] Exception Error when referencing a file
Hey to All on the Forum,
Just finished another VB project. Now I am moving on to something that will really challenge my skillset. I'm trying to encrypt and decrypt files. I have imported didisoft library for OpenPGP and now am getting a basic error when I'm referencing a file. Thought I would take the opportunity to ask how to do what I really want.
I get the following error:
System.IO.DirectoryNotFoundException was unhandled
HResult=-2147024893
Message=Could not find a part of the path 'C:\VB\Projects\Labs\Quiz2\CryptoKingdom\CryptoKingdom\bin\Debug\DataFiles\cryptomessage.txt'.
Obviously, the file is not there I am referencing; the code is right here:
Code:
pgp.EncryptFilePBE(New FileInfo("DataFiles\cryptomessage.txt"), _
"password", _
New FileInfo("DataFiles\OUTPUT.pgp"), _
asciiArmor)
I have another button on my form that I am pulling notepad up with. I prompt the user to create a file and save it. What I really want to do in my code is allow them to browse and choose the file they just created and have the method applied to that file. Can you help me or point me in the right direction?
Thanks folks,
sackerman.
-
Nov 29th, 2014, 05:33 PM
#2
Re: Exception Error when referencing a file
System.IO.DirectoryNotFoundException means it was looking for a valid directory and it wasn't found.
'C:\VB\Projects\Labs\Quiz2\CryptoKingdom\CryptoKingdom\bin\Debug\DataFiles\cryptomessage.txt'.
isnt a directory. it points to a file, the file crptomessage.
'C:\VB\Projects\Labs\Quiz2\CryptoKingdom\CryptoKingdom\bin\Debug\DataFiles\
is an example of a valid folder.
-
Nov 29th, 2014, 09:48 PM
#3
Re: Exception Error when referencing a file
Well, in this case, all it means is that some part of this directory structure:
C:\VB\Projects\Labs\Quiz2\CryptoKingdom\CryptoKingdom\bin\Debug\DataFiles\
wasn't found...it could mean that DataFiles doesn't exist in the bin\Debug folder, or some other part of it is off.
Obviously, the file is not there I am referencing
So then why reference it, if it doesn't exist?
-tg
-
Nov 30th, 2014, 01:12 PM
#4
Thread Starter
Member
Re: Exception Error when referencing a file
Originally Posted by techgnome
Well, in this case, all it means is that some part of this directory structure:
C:\VB\Projects\Labs\Quiz2\CryptoKingdom\CryptoKingdom\bin\Debug\DataFiles\
wasn't found...it could mean that DataFiles doesn't exist in the bin\Debug folder, or some other part of it is off.
So then why reference it, if it doesn't exist?
-tg
Right, so I changed that to be a different file so I don't get that error. However, I really want them to able to browse and choose the file they want, but that has to execute at this point in the code. I'll show you the code here.
Code:
Dim pgp As New PGPLib()
' specify should the output be ASCII or binary
Dim asciiArmor As Boolean = True
pgp.EncryptFilePBE(New FileInfo("c:\CryptoMessages\cryptomessage.txt"), _
"password", _
New FileInfo("c:\CryptoMessages\OUTPUT.pgp"), _
asciiArmor)
I'm not sure if it makes sense because I'm using didisoft .NET library for OpenPGP. It makes this stuff fairly easy, I'm just not sure how to put in the stuff I want. I'm very new.
All the above code executes with a click event from a button on my form. I can get it to work and encrypt the file. What I want, though, is where the code gets the file c:\cryptomessages\cryptomessage.txt, to instead prompt the user and allow them to browse for their file. The library will then encrypt that file; or, like it does now, will just encrypt that file to cryptomessage.pgp. I want to user to browse and select the file instead, then execute the code to encrypt it. I think I can move the file at that point where I want it.
Does that make sense?
-sackerman
Last edited by sackerman; Nov 30th, 2014 at 01:16 PM.
-
Nov 30th, 2014, 01:29 PM
#5
Re: Exception Error when referencing a file
you dont understand simple messages directory not found?
-
Nov 30th, 2014, 01:36 PM
#6
Thread Starter
Member
Re: Exception Error when referencing a file
Yes, I understand that message. Like I said, I fixed that by creating a directory and a file that do exist. I want to allow the user to browse and choose the file they want, and then encrypt it. I don't know how to do that. Although I'm trying to find out how; I'm looking for answers outside of here as well, and maybe I can just insert browsing for a file code into that section of my code. That's what I'm thinking. We'll see how it works.
-sackerman
-
Nov 30th, 2014, 02:18 PM
#7
Re: Exception Error when referencing a file
Use an OpenFileDialog.
Google it and learn how to use it.
-
Nov 30th, 2014, 02:24 PM
#8
Thread Starter
Member
Re: Exception Error when referencing a file
Tags for this Thread
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
|