如何将二进制字符串保存为文件?我从Excel发布二进制字符串。下面是该代码:我成功发布二进制文件,但不能上传文件在提到的位置将二进制文件保存为文件
[HttpPost]
public ActionResult PostLPFile(int LPKey, string ReadFile)
{
using (FileStream srReadFile = new FileStream(@"D:\Temp", FileMode.Create))
{
using (BinaryWriter writer = new BinaryWriter(srReadFile))
{
writer.Write(ReadFile);
writer.Close();
}
}
return View();
:
Sub PostFileAsBinary()
Dim Filename As String
Filename = "\\Network Drive\Test File\TestFile.pdf"
FileURL = "http://localhost:11212/Upload/BinaryFile/"
Dim ReadFile As String
Dim n As Integer
n = FreeFile()
Open Filename For Binary As n
ReadFile = String(LOF(n), vbNullChar)
Get n, , ReadFile
Close n
Debug.Print ReadFile
Set httpReq = New MSXML2.XMLHTTP
httpReq.Open "POST", FileURL & "?ID= " & 2, False
httpReq.SetRequestHeader "Content-Length", Len(ReadFile)
httpReq.send ReadFile
Debug.Print httpReq.responseText
ReadFile = ""
Set httpReq = Nothing
End Sub
这里是我的控制器操作\\Network Drive\Posted File
我想我将不得不将二进制字符串转换为流,我认为我正在努力。任何人都可以看到它并帮助吗?
@ user793468,你试过在本地写吗?在UNC地址之前先尝试一下,并确保它不会写入到其他域的IIS中。 (@squillman,我的坏) –
@one这其实不是我的问题,我只是把它清理了一下。 – squillman
@ one.beat.consumer我在本地拥有它:FileURL =“http:// localhost:11212/Upload/BinaryFile /” – user793468