PGPLib.DecryptFile - filename, directory name, or volume label syntax is incorrect

45 views
Skip to first unread message

Chad Bruels

unread,
May 30, 2017, 2:19:41 PM5/30/17
to DidiSoft Forum
I am using : DidiSoft.Pgp.PGPLib.DecryptFile(FileInfo encryptedFile, FileInfo privateKeyFile, String privateKeyPassword, FileInfo outputFile)

I am receiving : The filename, directory name, or volume label syntax is incorrect.

Here is my Decrypt method:


 
I have verified the output file is created if I comment out the DecryptFile() method. Yet when I do run the method then the "yes.txt" file is not left on the file system. 
I've made all the paths involved simpler than they were - removed periods and dashes. The encrypted file I received originally had a very long name with some dashes and underbars but I've renamed that as well to be very short and text only.

DidiSoft Support

unread,
May 30, 2017, 3:24:39 PM5/30/17
to didisof...@googlegroups.com, Chad Bruels
Hi Chad,

Can you display the result interpolated string $"{pathOut}yes.txt" - probably this will reveal the cause of the error.

Also there is no need to create the file before invoking pgp.DecryptFile, it will be created internally.

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com
On 30.05.2017 9:19 PM, Chad Bruels wrote:

Chad Bruels

unread,
May 30, 2017, 4:10:08 PM5/30/17
to DidiSoft Forum, chadb...@gmail.com, sup...@didisoft.com
I previously wrote that value out to a log file for own benefit. Here is what it resolves to: c:\RSMSurescripts\ConcurImport\2 Decrypt\yes.txt

Thank you for your attention.

Chad

DidiSoft Support

unread,
May 30, 2017, 4:20:44 PM5/30/17
to Chad Bruels, DidiSoft Forum
Hi Chad,

Have you debugged to see which line of your DecryptFile routine throws this error?

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com

Chad Bruels

unread,
May 30, 2017, 4:24:24 PM5/30/17
to DidiSoft Forum, chadb...@gmail.com, sup...@didisoft.com
The stack trace points to PGPLib.DecryptFile().

2017-05-30 14:13:15 - ERROR - The filename, directory name, or volume label syntax is incorrect.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at DidiSoft.Pgp.PGPLib.DecryptFile(String encryptedFileName, String privateKeyFileName, String privateKeyPassword, String outputFileName)
   at ConcurGP.MyExtensions.Decrypt(FileInfo encryptedFile, String pathOut, FileInfo privateKeyLocation, String privateKeyPhrase) in C:\TFS\Surescripts LLC\Concur GP Integration\ConcurGP.Solution\ConcurGP.Execute\MyExtensions.cs:line 27

Chad

DidiSoft Support

unread,
May 30, 2017, 4:49:47 PM5/30/17
to Chad Bruels, DidiSoft Forum
Hi Chad,

Can you please that you have invoked the same code from the screenshot sent earlier and the interpolated path is correct?

The method from the stack trace is:


DidiSoft.Pgp.PGPLib.DecryptFile(String encryptedFileName, String privateKeyFileName, String privateKeyPassword, String outputFileName)

whereas the screenshot uses

DidiSoft.Pgp.PGPLib.DecryptFile(FileInfo encryptedFileName, FileInfo privateKeyFileName, String privateKeyPassword, FileInfo outputFileName)


Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com

Chad Bruels

unread,
May 30, 2017, 4:58:17 PM5/30/17
to DidiSoft Forum, chadb...@gmail.com, sup...@didisoft.com
I have attempted both: 

2017-05-30 13:41:09 - ERROR - The filename, directory name, or volume label syntax is incorrect.

   at DidiSoft.Pgp.PGPLib.DecryptFile(FileInfo encryptedFile, FileInfo privateKeyFile, String privateKeyPassword, FileInfo outputFile)
   at ConcurGP.MyExtensions.Decrypt(FileInfo encryptedFile, String pathOut, FileInfo privateKeyLocation, String privateKeyPhrase) in C:\TFS\Surescripts LLC\Concur GP Integration\ConcurGP.Solution\ConcurGP.Execute\MyExtensions.cs:line 21

Chad

DidiSoft Support

unread,
May 31, 2017, 3:05:06 AM5/31/17
to didisof...@googlegroups.com, Chad Bruels
Hi Chad,

Can you try this way and tell me will there be any difference:

public static FileInfo Decrypt(this FileInfo encryptedFile, string pathOutput, FileInfo privateKeyLocation, string privateKeyPhrase)
{
        File.Create($"{pathOutput}yes.txt").Dispose();
       
        FileInfo decryptedFile = new FileInfo($"{pathOutput}yes.txt");
        PGPLib pgp = new PGPLib();
        using (Stream encryptedStream = encryptedFile.OpenRead())
        using (Stream privateKeyStream = privateKeyLocation.OpenRead())
        using (Stream outputStream = decryptedFile.Create())
        {
            return DecryptStream(encryptedStream, privateKeyStream, privateKeyPassword, outputStream);
        }       
        // pgp.DecryptFile(encryptedFile, privateKeyLocation, privateKeyPhrase, decryptedFile);
       
        return decryptedFile;
}

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com
--
You received this message because you are subscribed to the Google Groups "DidiSoft Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chad Bruels

unread,
May 31, 2017, 12:16:30 PM5/31/17
to DidiSoft Forum, chadb...@gmail.com, sup...@didisoft.com
This is failing on the OpenRead() for the private key file with the same "filename, directory, or volume label syntax is incorrect". 

Chad

Chad Bruels

unread,
May 31, 2017, 12:22:35 PM5/31/17
to DidiSoft Forum, sup...@didisoft.com
I see why, finally.. My path to the private key file mistakenly ended with a slash after the filename. Thank you for your assistance. 

Chad
Reply all
Reply to author
Forward
0 new messages