Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27077

Question about opening up files

$
0
0
I have a problem. When I go to open up a file on my computer for this application to run, it runs perfectly fine. Then, when I go to transfer the app to another computer, it bugs out saying, The filepath isnt correct for this computer. So I thought
instead of harcoding the path into it, I would use the

Code:

Application.StartupPath &
However, I cant get it to work, here is the whole code.

Code:

'Dim filename As String = "C:\Users\Brent\Documents\Visual Studio 2010\Projects\Golf\Golf\Quota.txt"
        Dim filename2 As String = Application.StartupPath & "\Quota.txt"

        Dim fields As String()

        Dim delimiter As String = ","
        Using parser As New TextFieldParser(filename2)
            parser.SetDelimiters(delimiter)
            While Not parser.EndOfData
                ' Read in the fields for the current line
                fields = parser.ReadFields()
                r = dt.NewRow
                r("Golfer Name") = fields(0)
                r("Quota 1") = fields(1)
                r("Quota 2") = fields(2)
                r("Quota 3") = fields(3)
                r("Quota 4") = fields(4)
                r("Quota 5") = fields(5)
                r("Quota 6") = fields(6)
                r("Average Quota") = CStr(CInt(fields(1)) + CInt(fields(2)) + CInt(fields(3)) + CInt(fields(4)) + CInt(fields(5))) / 6

                dt.Rows.Add(r)

            End While
        End Using

        dgv1.DataSource = dt


When I run filename it works, but I try to run filename2 it bugs out.

Thanks in advance.

Viewing all articles
Browse latest Browse all 27077

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>