本文整理汇总了C#中System.IO.MemoryStream.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.MemoryStream.WriteLine方法的具体用法?C# System.IO.MemoryStream.WriteLine怎么用?C# System.IO.MemoryStream.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryStream
的用法示例。
在下文中一共展示了System.IO.MemoryStream.WriteLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public override byte[] GetData()
{
if (CachedData != null)
return CachedData;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
for (int i = 0; i < Fields.Count; ++i)
{
HTTPFieldData field = Fields[i];
// Set the boundary
ms.WriteLine("--" + Boundary);
// Set up Content-Disposition header to our form with the name
ms.WriteLine("Content-Disposition: form-data; name=\"" + field.Name + "\"" + (!string.IsNullOrEmpty(field.FileName) ? "; filename=\"" + field.FileName + "\"" : string.Empty));
// Set up Content-Type head for the form.
if (!string.IsNullOrEmpty(field.MimeType))
ms.WriteLine("Content-Type: " + field.MimeType);
ms.WriteLine("Content-Length: " + field.Payload.Length.ToString());
ms.WriteLine();
// Write the actual data to the MemoryStream
ms.Write(field.Payload, 0, field.Payload.Length);
ms.Write(HTTPRequest.EOL, 0, HTTPRequest.EOL.Length);
}
// Write out the trailing boundary
ms.WriteLine("--" + Boundary + "--");
IsChanged = false;
// Set the RawData of our request
return CachedData = ms.ToArray();
}
}