Einzelnen Beitrag anzeigen

achi 3.0

Registriert seit: 7. Nov 2008
Ort: Köln
32 Beiträge
 
Delphi 5 Professional
 
#22

AW: Fremdes C# Steuern

  Alt 25. Jul 2013, 16:46
Ich denke mal das ich das hier auch irgendwie entschlüsseln muss. Weil hier wird der stream ja wirklich gesendet. Ich weiß nicht ob da mein Delphicode so direkt passt.

 
private string PostUploadFile(string filePath, string uri, string postMethod, bool validate)
{
string fileName = this.ExtractFileName(filePath);
if (validate && !this.IsValidFileName(fileName))
return "Invalid file name! File name must match one of those found in default configuration!";
HttpWebRequest postRequest = HttpUtility.CreatePostRequest(uri);
byte[] bytes1 = Encoding.UTF8.GetBytes(HttpUtility.CreateFilePostDataString(filePath, "text/xml"));
byte[] bytes2 = Encoding.UTF8.GetBytes(postMethod);
byte[] bytes3 = Encoding.UTF8.GetBytes(HttpUtility.CreateBoundaryPostDataString());
FileStream fileStream = new FileInfo(filePath).Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
long num = (long) bytes1.Length + fileStream.Length + (long) bytes2.Length + (long) bytes3.Length;
postRequest.ContentLength = num;
Stream requestStream = ((WebRequest) postRequest).GetRequestStream();
requestStream.Write(bytes1, 0, bytes1.Length);
byte[] buffer = new byte[fileStream.Length];
int count;
while ((count = fileStream.Read(buffer, 0, buffer.Length)) != 0)
requestStream.Write(buffer, 0, count);
requestStream.Write(bytes2, 0, bytes2.Length);
requestStream.Write(bytes3, 0, bytes3.Length);
requestStream.Close();
fileStream.Close();
new StreamReader(postRequest.GetResponse().GetResponseStream()).ReadToEnd();
return "";
}
  Mit Zitat antworten Zitat