469,611 Members | 1,714 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

Need help with saving a local file through a web service to my server

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


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)




f = Nothing

m = Nothing

Return "Success"

Case Else

Return "Failure"

End Select

Catch ex As Exception

Return ex.Message

End Try

End Function
Nov 21 '05 #1
0 1372

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by D. Shane Fowlkes | last post: by
3 posts views Thread by Justnew | last post: by
13 posts views Thread by Siegfried Heintze | last post: by
1 post views Thread by Phillip N Rounds | last post: by
11 posts views Thread by Kirk | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.