I have created a web service that will be running on one of our servers. It
has a function in it called UploadFile. The way we would like to use it is
the user types in the url
http://MyWebSite/Upload.aspx?FileName=C:\Test\Test.txt. When the user gets
to this page, the code behind it will hit my web service and copy the file
specified in Request.QueryString("FileName") to our server. It works great
on my local development box but when I move it to the server, I keep getting
Could not find a part of the path "C:\Test\Test.txt".
What I imagine is happening is that it is looking for C:\Test\Test.txt on my
server now that I have moved it over. How do I specify a local file and send
it to the web service on my server and get it to upload. Below is the code
that I am using in the web service. Thanks for any help on this!
<WebMethod(Description:="Upload a single file through a web page passing a
parameter called 'FileName'.")> _
Public Function UploadFile(ByVal fs() As Byte, ByVal FlName As String) As
String
Try
Dim m As New MemoryStream(fs)
Dim FileExtension As String = FlName.Substring(FlName.Length - 3, 3)
Select Case FileExtension
Case "txt", "xml"
Dim f As New FileStream("\\myserver\" & FlName, FileMode.Create)
m.WriteTo(f)
m.Close()
f.Close()
f = Nothing
m = Nothing
Return "Success"
Case Else
Return "Failure"
End Select
Catch ex As Exception
Return ex.Message
End Try
End Function