我想在服务器代码运行时将字节数组写入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
}
}
我的代码是否正确?请提出任何建议。