-
Notifications
You must be signed in to change notification settings - Fork 267
Closed
Labels
state: in workIssues that are currently worked onIssues that are currently worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality
Description
When you copy a file the file contents gets passed as a reference instead of being cloned. If I copy FileA.txt to FileB.txt, they will both point to the same contents object. When I then change the contents of FileA.txt, FileB.txt will also update.
var mockFileSystem = new MockFileSystem();
mockFileSystem.AddFile("C:\\Test1.txt", "");
mockFileSystem.File.Copy("C:\\Test1.txt", "C:\\Test2.txt");
var before1 = mockFileSystem.FileInfo.FromFileName("C:\\Test1.txt").Length;
var before2 = mockFileSystem.FileInfo.FromFileName("C:\\Test2.txt").Length;
using (var stream = mockFileSystem.File.Open("C:\\Test1.txt", FileMode.Open, FileAccess.ReadWrite))
{
var binaryWriter = new System.IO.BinaryWriter(stream);
binaryWriter.Seek(0, SeekOrigin.Begin);
binaryWriter.Write("Some text");
}
var after1 = mockFileSystem.FileInfo.FromFileName("C:\\Test1.txt").Length;
var after2 = mockFileSystem.FileInfo.FromFileName("C:\\Test2.txt").Length;
Metadata
Metadata
Assignees
Labels
state: in workIssues that are currently worked onIssues that are currently worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality