我正在使用this example,虽然我点击上传时转移方法已流式传输,但客户端上的内存消耗会跃升至1GB。传输完成后,内存不会减少。我的代码如下:
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
if (File.Exists(openFileDialog1.FileName))
{
//System.IO.FileInfo fileInfo = new System.IO.FileInfo(openFileDialog1.FileName);
FileTransferServiceReference.ITransferService clientUpload = new FileTransferServiceReference.TransferServiceClient();
FileTransferServiceReference.RemoteFileInfo uploadRequestInfo = new RemoteFileInfo();
uploadRequestInfo.FileName = openFileDialog1.FileName;
uploadRequestInfo.Length = new FileInfo(openFileDialog1.FileName).Length;
uploadRequestInfo.FileByteStream = File.OpenRead(openFileDialog1.FileName);
clientUpload.UploadFile(uploadRequestInfo);
}
}
在App.config上有
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.web>
<httpRuntime maxRequestLength="2097150"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://62.1.193.176/transferTEST/wcfTest.TransferService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"
contract="FileTransferServiceReference.ITransferService" name="BasicHttpBinding_ITransferService" />
</client>
</system.serviceModel>
</configuration>