how do I get streamwriter to work on server?

Posted on 2008-11-06
Last Modified: 2012-05-05
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

Question by:bschave2
    LVL 11

    Expert Comment

    Are the security settings right. has the account write rights on the server and the share ?

    Author Comment

    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.
    LVL 11

    Expert Comment

    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.

    Author Comment

    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?
    LVL 11

    Expert Comment

    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.

    Author Comment

    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.
    LVL 11

    Accepted Solution

    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.

    Author Comment

    I found the issue. IIS NTSF wasn't set to basic.

    Author Closing Comment

    I will award you the point. thanks for trying to help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now