rbulph Posted December 22, 2005 Posted December 22, 2005 I'm trying to save files. They save OK the first time, i.e. when they're created, but I can't successfully save the changes. Here's the code I'm using: Dim TestFileStream As Stream TestFileStream = File.Open(FullPath, FileMode.Create, FileAccess.Write) Dim serializer As New BinaryFormatter serializer.Serialize(TestFileStream, Me.SerializationCol) TestFileStream.Close() In relation to FileAccess.Write the helpfile says: "Specifies that the operating system should create a new file. If the file already exists, it will be overwritten. This requires FileIOPermissionAccess.Write. System.IO.FileMode.Create is equivalent to requesting that if the file does not exist, use CreateNew; otherwise, use Truncate. ", but the link for FileIOPermissionAccess.Write is broken. How do I get my files to save properly? Quote
HJB417 Posted December 22, 2005 Posted December 22, 2005 try calling FileStream.Flush before closing the filestream. Quote
rbulph Posted December 23, 2005 Author Posted December 23, 2005 try calling FileStream.Flush before closing the filestream. Makes no difference, unfortunately. Quote
HJB417 Posted December 23, 2005 Posted December 23, 2005 For diagnostic purposes, try saving it to a MemoryStream and see how many bytes were written to it. Quote
rbulph Posted December 29, 2005 Author Posted December 29, 2005 Fixed it thanks. I was missing something very simple - too much Christmas spirit on my part, no doubt. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.