Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- memoryStream.WriteTo(fileStream);
- fileStream.CopyTo(memoryStream);
- memoryStream.CopyTo(fileStream);
- using (FileStream file = new FileStream("file.bin", FileMode.Create, System.IO.FileAccess.Write)) {
- byte[] bytes = new byte[ms.Length];
- ms.Read(bytes, 0, (int)ms.Length);
- file.Write(bytes, 0, bytes.Length);
- ms.Close();
- }
- using (MemoryStream ms = new MemoryStream())
- using (FileStream file = new FileStream("file.bin", FileMode.Open, FileAccess.Read)) {
- byte[] bytes = new byte[file.Length];
- file.Read(bytes, 0, (int)file.Length);
- ms.Write(bytes, 0, (int)file.Length);
- }
- using (FileStream file = new FileStream("file.bin", FileMode.Create, FileAccess.Write)) {
- memoryStream.WriteTo(file);
- }
- using (FileStream file = new FileStream("file.bin", FileMode.Open, FileAccess.Read)) {
- byte[] bytes = new byte[file.Length];
- file.Read(bytes, 0, (int)file.Length);
- ms.Write(bytes, 0, (int)file.Length);
- }
- MemoryStream ms = new MemoryStream(bytes, writable: false);
- byte[] testData = new byte[] { 104, 105, 121, 97 };
- var ms = new MemoryStream(testData, 0, 4, false, true);
- Assert.AreSame(testData, ms.GetBuffer());
- MemoryStream ms = new MemoryStream();
- FileStream file = new FileStream("file.bin", FileMode.Create, FileAccess.Write);
- ms.WriteTo(file);
- file.Close();
- ms.Close();
- MemoryStream ms = new MemoryStream();
- using (FileStream fs = File.OpenRead(file))
- {
- fs.CopyTo(ms);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement