Can't extract excel file from resources folder

Hello,
I am trying to extract an excel template that I have added to the resource folder of the project.  The code below (translated from portuguese) is designed to extract a file, in this case a template, and write it to a temp folder on the users machine.  However when I run the code, I can't find the file.  I understand most of the code and I think the problem isin
 Dim currentAssembly As Reflection.Assembly = Reflection.Assembly.GetEntryAssembly
 Assemblies are new to me so I'd like get some information on what they are.  I have a hazy notion of what they do but I need more information
Private Function GetResourceFile(ByVal fileName As String) As String

        Try

            'Create a name / temporary location for the file. By default it creates a
            ' file with extension *. tmp, and so you need to change the *. exe
            Dim tempPath As String = IO.Path.ChangeExtension(IO.Path.GetTempFileName(), ".xltx")

            ' Checks the application name (Assembly) 
            Dim currentAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly
            'MessageBox.Show(currentAssembly.GetName.ToString)
            ' Verify 
            Dim arrResources As String() = currentAssembly.GetManifestResourceNames()
            MessageBox.Show(currentAssembly.GetManifestResourceNames.Count.ToString())


            For Each resource As String In arrResources

                'Check if the resource has the name of the file to extract
                If resource.Contains(fileName) Then

                    ' Reads the resources of the executable to a Stream
                    Using resourceStream As IO.Stream = currentAssembly.GetManifestResourceStream(resource)

                        'Creates a new FileStream that will write the final file
                        Using writer As New IO.FileStream(tempPath, IO.FileMode.Create, IO.FileAccess.Write)

                            Const size As Int16 = 4096
                            Dim bytes(size) As Byte
                            Dim numBytes As Int32 = 0

                            'Write all bytes of Stream created using
                            'The FileStream and the method Write () on a loop
                            Do
                                numBytes = resourceStream.Read(bytes, 0, size)
                                writer.Write(bytes, 0, numBytes)

                            Loop While (numBytes > 0)

                        End Using ' writer

                    End Using ' resourceStream

                    ' Returns the file location
                    Return tempPath
                
                End If

            Next

            ' If you have not found the desired file
            Return String.Empty

        Catch ex As Exception
            Return String.Empty
        End Try

    End Function

Open in new window

Juan VelasquezAsked:
Who is Participating?

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

x
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.

Juan VelasquezAuthor Commented:
I found the solution.  I changed the property of the excel file in the resource folder to Embedded Resource
0

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
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
Visual Basic.NET

From novice to tech pro — start learning today.