0
我在客戶端獲取文件的函數,從中創建一個字節數組並將該數組發送到服務器上的Web服務! 這是客戶端的功能:ArgumentOutOfRangeException使用BinaryWriter寫入文件
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
服務器上現在ASMX web服務,被髮送的字節數組轉換該字節數組文件,該文件是需要被保存在服務器上。這是Web服務需要做到這一點的功能:
<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
後,我把這個web服務我收到此錯誤:
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)
路徑上的文件需要保存服務器是d:\存檔 我設置了這個文件夾的權限,我給這個文件夾的aspnet用戶完全控制,但即使在那之後,我得到相同的錯誤!