コード例 #1
0
        /// <summary>
        /// Writes the value to the specified <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">The stream the value should be written to.</param>
        /// <param name="boundary">The multipart boundary.</param>
        /// <param name="newLine">The characters used to indicate a new line.</param>
        /// <param name="isLast">Whether the value is the last in the request body.</param>
        public void WriteToMultipartStream(Stream stream, string boundary, string newLine, bool isLast)
        {
            HttpPostData.Write(stream, "--" + boundary + newLine);
            HttpPostData.Write(stream, "Content-Disposition: form-data; name=\"" + Name + "\"" + newLine);
            HttpPostData.Write(stream, newLine);

            HttpPostData.Write(stream, Value);

            HttpPostData.Write(stream, newLine);
            HttpPostData.Write(stream, "--" + boundary + (isLast ? "--" : "") + newLine);
        }
コード例 #2
0
        /// <summary>
        /// Writes the value to the specified <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">The stream the value should be written to.</param>
        /// <param name="boundary">The multipart boundary.</param>
        /// <param name="newLine">The characters used to indicate a new line.</param>
        /// <param name="isLast">Whether the value is the last in the request body.</param>
        public void WriteToMultipartStream(Stream stream, string boundary, string newLine, bool isLast)
        {
            HttpPostData.Write(stream, "--" + boundary + newLine);
            HttpPostData.Write(stream, "Content-Disposition: form-data; name=\"" + Name + "\"; filename=\"" + FileName + "\"" + newLine);
            HttpPostData.Write(stream, "Content-Type: " + ContentType + newLine);
            HttpPostData.Write(stream, newLine);

            stream.Write(Data, 0, Data.Length);

            HttpPostData.Write(stream, newLine);
            HttpPostData.Write(stream, newLine);
            HttpPostData.Write(stream, "--" + boundary + (isLast ? "--" : "") + newLine);
        }