I Need A Class Tha Can Transfer Files Using Webservice On Client Machines

Nonasoft

Member
Joined
May 3, 2007
Messages
16
Programming Experience
1-3
I want to design a webservice that can enable me send data to and from client machine. I used code below but it was giving me errors. I changed FileStream to StreamWriter and StreamReader, it complained about using C drive since I don't have access to it Dim fs1 As New FileStream("C:\" & fo.Name, FileMode.Create).

When I changed Dim fs1 As New FileStream("C:\" & fo.Name, FileMode.Create) to dim fs1 as new StreamWriter(path & fiename) and it worked but when I open the file it gives me strange xters.

Please help me look at the code below and suggest possible solutions if not a new idea.



VB.NET:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.IO
<WebService(Namespace:="http://mysite.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> <System.Serializable()> _
Public Class Service
    Inherits System.Web.Services.WebService

    <WebMethod()> _
        Public Function FilePosted(ByVal Filename As String) As String


        Try
            Dim path As String = Context.Server.MapPath("~/")
            Dim fo As New FileInfo(Filename)
            Dim fs As New FileStream(Filename, FileMode.Open)

            Dim fs1 As New FileStream("C:\" & fo.Name, FileMode.Create)
            Dim nBytes As Integer = fs.Length
            Dim ByteArray(nBytes) As Byte


            Do While Not fs.Read(ByteArray, 0, nBytes) = 0
                fs1.Write(ByteArray, 0, nBytes)
            Loop

            fs1.Dispose()
            fs.Dispose()

            Return "Success"

        Catch ex As Exception
            Return "Failed"

        End Try


    End Function



End Class

Finally is there anyway I could know scanners connected to my computer?
 
Last edited by a moderator:
Top Bottom