Help with decrypting file using


How do I modify the code to only decrypt \Data\LinkFiles\LinkFinal.xml instead of all xml files in the folder?

For Each File In Directory.GetFiles(Application.StartupPath & "\Data\LinkFiles")

                fslinkBEL = New System.IO.FileStream(File, IO.FileMode.Open)
                dtsetlinkBEL = New DataSet
                Dim sec As New Security
                For t As Integer = 0 To dtsetlinkBEL.Tables.Count - 1
                    For i As Integer = 0 To dtsetlinkBEL.Tables(t).Rows.Count - 1
                        For j As Integer = 0 To dtsetlinkBEL.Tables(t).Columns.Count - 1
                            If Not IsDBNull(dtsetlinkBEL.Tables(t).Rows(i).Item(j)) Then
                                'dtsetlinkBEL.Tables(t).Rows(i).Item(j) = sec.psEncrypt(dtsetlinkBEL.Tables(t).Rows(i).Item(j))
                                dtsetlinkBEL.Tables(t).Rows(i).Item(j) = sec.psDecrypt(dtsetlinkBEL.Tables(t).Rows(i).Item(j))
                            End If
                MsgBox(Err.Description & "FileName  " & File)
            End Try
        MsgBox("All Files Decrypted")

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
You can remove the loop code (lines 1,2 and 23) and insert this line at line 1:
Dim File As String = Application.StartupPath & "Data\LinkFiles\LinkFinal.xml"

Open in new window

The try/catch block code remains the same. I just initialize File variable with your requested value.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vcharlesAuthor Commented:

Thanks for the code, how do you check to see if the file is encrypted before you attempt to decrypt it?

Miguel OzSoftware EngineerCommented:
Regarding post question, the short answer is : NO.
If a code can determine this, it could mean that the encryption algorithm was broken. The goal of the encryption is to produce a file that looks like a random chunk of data.
Having said that you could add an extra node element to your xml, this element should store a value that your program reads and determine whether the file contains encrypted/decrypted info.
vcharlesAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.