I have a web service that is currently calling the DOS command copy to put a text file to a specified network share. This is the code:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Xml

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class ZebraPrinter
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function PrintCaseLabels(ByVal input1 As informationtopass) As returnparams
Dim adapter As New System.Data.SqlClient.SqlDataAdapter
Dim ds As New System.Data.DataSet
Dim stringxml As String
Dim rp As New returnparams
'Dim sql As String
Dim cn As New System.Data.SqlClient.SqlConnection
cn.ConnectionString = "database=ee8idbbd;server=jomar;uid=reports;pwd=reports;Max Pool Size=300"
cn.Open()
Dim cmd As New System.Data.SqlClient.SqlCommand
Try
cmd.Connection = cn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "bdg_proccaselabelstoprint"
cmd.Parameters.AddWithValue("@STYLE", input1.STYLE.ToString)
cmd.Parameters.AddWithValue("@COLORCODE", input1.color.ToString)
cmd.Parameters.AddWithValue("@SIZECODE", input1.size.ToString)
cmd.Parameters.AddWithValue("@CASEQUANTITY", input1.quantity)
cmd.Parameters.AddWithValue("@COUNTRY", input1.country.ToString)
adapter.SelectCommand = cmd
adapter.Fill(ds)
stringxml = ds.Tables(0).Rows(0).Item(0)

Using writer As New System.IO.StreamWriter(Server.MapPath("/") & "Newoutput.xml")
writer.Write(stringxml)
End Using
Dim transformer As New System.Xml.Xsl.XslCompiledTransform
Dim document As New XmlDocument
document.Load(Server.MapPath("/") & "Newoutput.xml")
rp.casenumber = 0
Dim navigator As XPath.XPathNavigator = document.CreateNavigator
Dim list = document.GetElementsByTagName("casenumber")
For Each item As System.Xml.XmlElement In list
rp.casenumber = item.InnerText
Next

transformer.Load(Server.MapPath("/") & "XSLTFile1.xslt")

Dim output As New StringWriter
transformer.Transform(navigator, Nothing, output)
Dim newstream As New FileStream(Server.MapPath("/") & "NewOutput.txt", FileMode.Create)
Dim newwriter As New StreamWriter(newstream)
newwriter.Write(output.ToString)
newwriter.Close()
output.Close()
Process.Start("cmd.exe", "/c type " & Server.MapPath("/") & "NewOutput.txt >" & input1.networkshare.ToString)

Catch ex As Exception
Dim exceptionstream As New FileStream(Server.MapPath("/") & "error.txt", FileMode.Create)
Dim excwriter As New StreamWriter(exceptionstream)
excwriter.Write(ex.ToString)
excwriter.Close()
Finally
cn.Close()
cn = Nothing

End Try
Return rp
End Function

End Class

Public Class InformationToPass
Public STYLE As String
Public color As String
Public size As String
Public quantity As Long
Public country As String
Public networkshare As String
End Class

Public Class returnparams
Public casenumber As String
End Class



It appears doing this might be causing some problems and our front-end programmer suggested I see if I can output the stream "output" directly to the network shared printer specified by the SOAP request.

Is this possible? This is VS 2010