我想在服务器代码正在运行上将字节数组写入 txt 文件,但它没有显示服务器文件上的任何内容..我该如何编写它
private void button1_Click(object sender, RoutedEventArgs e)
{
Stream mystream = Application.GetResourceStream(new Uri(@"LoadVideo;component/test.mp4", UriKind.Relative)).Stream;
byte[] myarray = new byte[mystream.Length];
int bytesRead = mystream.Read(myarray, 0, (int)mystream.Length);
mystream.Close();
WebClient wc = new WebClient();
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
Uri u = new Uri("http://xyz/New.txt");
wc.OpenWriteAsync(u, null, new object[] { myarray, bytesRead }); // Upload the file to the server
}
void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e) // The upload completed
{
if (e.Error == null)
{
// Upload completed without error
}
}
我的代码正确吗?请提出任何建议。