Hi,
I have checked all the prior forum questions on this topic, but none of the options seem to be working for me.

I am creating an output file that goes into a specific folder for getting MP3 file information.

When I run inside of Visual Studio Community 15, it works great ... no errors. When I take the EXE and create a new folder for the actual application and run by itself is when I get the error. I have tried turning on the UAC to Admin rights, with no luck.

Here is my code

Private Sub cmdCreateFile_Click(sender As Object, e As EventArgs) Handles cmdCreateFile.Click
        Dim InFolder As String = txtFolderToBrowse.Text
        Dim sInFile As String
        Dim sTitle As String
        Dim sArtist As String
        Dim MyData As MediaID3Structure
        Dim sOutput As String
        Dim sCurrentPath As String
        Dim filePath As String
        Dim fileName As String
        Dim swFile As StreamWriter

        Try
            If txtFolderToBrowse.Text = "" Then
                MsgBox("You haven't selected a folder that has MP3 files")
                txtFolderToBrowse.Focus()
                Exit Sub
            End If

            If VisualBasic.Left(InFolder, 1) <> "\" Then
                InFolder = InFolder & "\"
            End If

            sCurrentPath = Application.StartupPath & "\SongFilesForUpload\"

            fileName = "MusicFiles_" & Format(Now(), "yyyyMMdd_hhmmss") & ".csv"

            filePath = Path.Combine(sCurrentPath, fileName)

            Dim OutFile As String = filePath

            swFile = New System.IO.StreamWriter(OutFile)
            sOutput = "Titile,Artist"
            swFile.WriteLine(sOutput)

            For Each i As String In Directory.GetFiles(InFolder, "*.mp3")
                Try
                    sInFile = Path.GetFileName(i)    'Get name of file so that you can get the information

                    MyData = GetMediaData(InFolder & sInFile)

                    sTitle = Replace(Replace(Replace(MyData.Title, ",", ",,"), "&", "&&"), "+", "++")
                    sArtist = Replace(Replace(Replace(MyData.Artist, ",", ",,"), "&", "&&"), "+", "++")

                    sOutput = sTitle & "," & sArtist
                    swFile.WriteLine(sOutput)
                Catch ex As Exception
                    MsgBox("You Received the following error:  " & ex.Message)
                End Try
            Next
            swFile.Close()
            MsgBox("File has been created.  Open folder to review")
        Catch ex As Exception
            MsgBox("You Received the following error:  " & ex.Message)
        End Try
    End Sub

Any help would be greatly appreciated.

Try using VS's deployment tools next time as creating a folder and dropping exe's in there can be trouble as in permissions, ownership etc.

commented: I am unfamiliar with VS's deplyment tools. I am not sure what to look for +1

What is the exact folder name that gives the error? Don't assume the folder name. Display it then post the output here.

What happens when you try to manually copy a file to that folder?

commented: The program goes under the CreateSongFileForUpload and the output file goes under SongFilesForUpload +1

The EXE, running by itself as you say, is working with no problem for me.

    Private Sub cmdCreate_File_Click(sender As Object, e As EventArgs) Handles cmdCreate_File.Click
        Dim InFolder As String = txtFolderToBrowse.Text
        Dim sInFile As String
        Dim sTitle As String
        Dim sArtist As String
        Dim MyData As MediaID3Structure
        Dim sOutput As String
        Dim sCurrentPath As String
        Dim filePath As String
        Dim fileName As String
        Dim swFile As StreamWriter

        Try
            If txtFolderToBrowse.Text = "" Then
                MsgBox("You haven't selected a folder that has MP3 files")
                txtFolderToBrowse.Focus()
                Exit Sub
            End If

            If Microsoft.VisualBasic.Left(InFolder, 1) <> "\" Then
                InFolder = InFolder & "\"
            End If

            sCurrentPath = Application.StartupPath & "\SongFilesForUpload\"

            fileName = "MusicFiles_" & Format(Now(), "yyyyMMdd_hhmmss") & ".csv"

            filePath = Path.Combine(sCurrentPath, fileName)

            Dim OutFile As String = filePath

            swFile = New System.IO.StreamWriter(OutFile)
            sOutput = "Titile,Artist"
            swFile.WriteLine(sOutput)

            For Each i As String In Directory.GetFiles(InFolder, "*.mp3")
                Try
                    sInFile = Path.GetFileName(i)    'Get name of file so that you can get the information

                    MyData = GetMediaData(InFolder & sInFile)

                    sTitle = Replace(Replace(Replace(MyData.Title, ",", ",,"), "&", "&&"), "+", "++")
                    sArtist = Replace(Replace(Replace(MyData.Artist, ",", ",,"), "&", "&&"), "+", "++")

                    sOutput = sTitle & "," & sArtist
                    swFile.WriteLine(sOutput)
                Catch ex As Exception
                    MsgBox("You Received the following error:  " & ex.Message)
                End Try
            Next
            swFile.Close()
            MsgBox("File has been created.  Open folder to review")
        Catch ex As Exception
            MsgBox("You Received the following error:  " & ex.Message)
        End Try
    End Sub
    Public Structure MediaID3Structure
        Dim Artist As String
        Dim Album As String
        Dim Title As String
        Dim Genre As String
        Dim Year As String
    End Structure
    Public Function GetMediaData(ByVal FileName As String) As MediaID3Structure
        Dim NewID3 As MediaID3Structure
        Dim SeekPoint As Integer
        'Dim HasTag As Boolean
        Dim FS As New FileStream(FileName, FileMode.Open) 'Open The File And Assign It To FS
        Dim BR As New BinaryReader(FS) 'Create A New Reader For FS

        'NOTE: If you don't get any results from tracks you know have TAGS try changing
        'SeekPoint to 127.
        SeekPoint = 128
        'Locate The "TAG" Text. Used To Be LOF(FileNum-127) But Now Seems To Be At LOF(FileNum-128)
        FS.Seek(FS.Length - (SeekPoint), SeekOrigin.Begin)
        'Read 3 Chracters
        If BR.ReadChars(3) = "TAG" Then
            'If TAG Was Found Continue Reading The Remaining Data (Remember Once A Binary File Has Been Read 
            'The Cursor Automatically Seeks Foward.
            NewID3.Title = Replace(BR.ReadChars(30), Chr(0), "")
            NewID3.Artist = Replace(BR.ReadChars(30), Chr(0), "")
            NewID3.Album = Replace(BR.ReadChars(30), Chr(0), "")
        End If
        'Just Tidy Up The Data (Not Neccassary For The Binary Example)
        If NewID3.Album = "" Then NewID3.Album = "Unknown"
        If NewID3.Artist = "" Then NewID3.Artist = "Unknown"
        If NewID3.Title = "" Then NewID3.Title = "Unknown"
        NewID3.Year = "Unknown"
        NewID3.Genre = "Unknown"
        FS.Close()
        BR.Close()
        Return NewID3
    End Function

I see a probable issue with line 24 where you declare the SongFilesForUpload to be in the app path. That could bomb out if you place this app in Program Files. I wonder if you took any course about developing apps for Windows that covered how your app lives in Program Files and the data is per user in each user's home directory.

I really have never used the creation of Install software. It has been awhile since I created a Windows application. I did check out the link that rproffitt added. It was very helpful.

I use MalwareBytes and now I am getting a MachineLearning/Anomalous.95% when I run after installing. What is that?

I got it working ... I had to turn off the RansomeWare Protection in both Malwarebytes and the CyberCapture Technology in Avast.

I am not sure how I would be able to get around this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.