how do I get streamwriter to work on server?

I have a file that needs to be created on another server other than the one the stramwriter app is running on. I have tested the link on my local with the link to the correct server, but when I put the application in dev, I get an webunhandled acception.

any help would be much appreciated...code in snippet
strSql11 = "Select FromDate,ToDate,MeterNumber,MeterNumberSub,ConvertedMCF,ConvertedMMBTU from itpwork where FromDate>= '" & FromDate & "' and ToDate<= '" & ToDate & "' "
        cmd = New MySqlCommand(strSql11, conn)
        da = New MySqlDataAdapter(cmd)
        ds11 = New DataSet()
        'DataTable2CSV(ds11.Tables(0), "K:\saIT\ITWORK.txt")
        'Development Server
        DataTable2CSV(ds11.Tables(0), "\\\saIT\ITWORK.txt")
        'DataTable2CSV(ds11.Tables(0), "f:\inetpub\ftproot\trucktickets\ITWORK.txt")
    End Sub
    Sub DataTable2CSV(ByVal table As DataTable, ByVal filename As String)
        DataTable2CSV(Table, filename, vbTab)
    End Sub
    Sub DataTable2CSV(ByVal table As DataTable, ByVal filename As String, _
        ByVal sepChar As String)
        Dim writer As System.IO.StreamWriter = Nothing
            writer = New System.IO.StreamWriter(filename)
            ' first write a line with the columns name
            Dim sep As String = " "
            Dim builder As New System.Text.StringBuilder
            'For Each col As DataColumn In table.Columns
            'sep = sepChar
            ' then write all the rows
            For Each row As DataRow In table.Rows
                sep = ""
                builder = New System.Text.StringBuilder
                For Each col As DataColumn In table.Columns
                    sep = sepChar
            If Not writer Is Nothing Then writer.Close()
        End Try
    End Sub

Open in new window

Who is Participating?
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.

melmersSenior Software Deveolper/ArchitectCommented:
Are the security settings right. has the account write rights on the server and the share ?
bschave2Author Commented:
yes, I have full access to the server and folder. It works fine on my machine with the server path, but when I put it on a server, it bombs.
melmersSenior Software Deveolper/ArchitectCommented:
when you do it on your machine and the webserver runs under your user it has your rights but when it runs under the webserver account it has only the rights of the instance.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

bschave2Author Commented:
if I am trying to save the file on a network drive, would I need to do this. What would I need to save the file on the network?
melmersSenior Software Deveolper/ArchitectCommented:
It's the same there are no difference if you save the file on a network drive or on the network with the unc path. look at the security setting of the destination folder.
Add there the ASP.NEt USer form your network server or create a AD Group where you add the ASP.NET account of your server and then add it to the security tab of the destination folder.
bschave2Author Commented:
I get this error when trying to copy the file from the server the app is running on to the network drive of choice.

The account used is a computer account. Use your global user account or local user account to access this server.
melmersSenior Software Deveolper/ArchitectCommented:
Ok, when you have access to the server create a user who have access to the webserver and to your fileserver then create a new apppool and give him the identity of your created user.

On your website configuration set your website the new created apppool.

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
bschave2Author Commented:
I found the issue. IIS NTSF wasn't set to basic.
bschave2Author Commented:
I will award you the point. thanks for trying to help
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.