I have function on client side that get file, make a byte array from it and send that array to the web service on server! This is the function on client side:
Public Function GetFile(ByVal filename As String) As Byte()
Dim binReader As New BinaryReader(File.Open(filename, FileMode.Open))
binReader.BaseStream.Position = 0
Dim binFile As Byte() = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length))
binReader.Close()
Return binFile
End Function
Now asmx webservice on server, get sent byte array and convert that byte array into file which is need to be saved on server. This is the function in webservice that need to do that:
<WebMethod()> _
Public Sub PutFile(ByVal buffer As Byte(), ByVal filename As String)
Dim binWriter As New BinaryWriter(File.Create((filename), FileMode.CreateNew, FileAccess.ReadWrite))
binWriter.Write(buffer)
binWriter.Close()
End Sub
After i call this webservice i am getting this error:
Server was unable to process request. ---> System.ArgumentOutOfRangeException: Enum value was out of legal range. Parameter name: options at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
Path on server that file need to be saved is D:\Archive I set permission for this folder and i give aspnet user full control on this folder, but even after that I am getting same error!