GiovanniPolese Well-Known Member Licensed User Longtime User Jun 2, 2024 #1 Hi. My problem is to write on disk various Lists, in sequence, on same file. The saving sequence is: Code: File.Delete(InternalWorkDir,FileUndo) File.WriteList(InternalWorkDir,FileUndo,Layers) File.WriteMap(InternalWorkDir,FileUndo,colorMap) b=rvs.ConvertObjectToBytes(layerMap.Size) ' just an integer File.WriteBytes(InternalWorkDir,FileUndo,b) The list, the map and the integer are saved with no error. But when I try to load the data with: Code: Layers.Initialize ' not sure if necessary Layers=File.ReadList(InternalWorkDir,FileUndo) colorMap=File.ReadMap(InternalWorkDir,FileUndo) b=File.ReadBytes(InternalWorkDir,FileUndo) size=rvs.ConvertBytesToObject(b) I don't find the same data, actually I find nothing. If I just save and reload the first list, it works. It seems that wrtiting destroys previous data. So I am missing something, of course. Using TextWriter is out of question, because, besides the above list and map, I have much more data to save, in other maps and atrays, and the process will be intolerably slow. I successfully did the process with RandomAccesFile, but it is too slow on huge data. Something working faster than RandomAccesFile is necessary. Thanks for any hint
Hi. My problem is to write on disk various Lists, in sequence, on same file. The saving sequence is: Code: File.Delete(InternalWorkDir,FileUndo) File.WriteList(InternalWorkDir,FileUndo,Layers) File.WriteMap(InternalWorkDir,FileUndo,colorMap) b=rvs.ConvertObjectToBytes(layerMap.Size) ' just an integer File.WriteBytes(InternalWorkDir,FileUndo,b) The list, the map and the integer are saved with no error. But when I try to load the data with: Code: Layers.Initialize ' not sure if necessary Layers=File.ReadList(InternalWorkDir,FileUndo) colorMap=File.ReadMap(InternalWorkDir,FileUndo) b=File.ReadBytes(InternalWorkDir,FileUndo) size=rvs.ConvertBytesToObject(b) I don't find the same data, actually I find nothing. If I just save and reload the first list, it works. It seems that wrtiting destroys previous data. So I am missing something, of course. Using TextWriter is out of question, because, besides the above list and map, I have much more data to save, in other maps and atrays, and the process will be intolerably slow. I successfully did the process with RandomAccesFile, but it is too slow on huge data. Something working faster than RandomAccesFile is necessary. Thanks for any hint
LucaMs Expert Licensed User Longtime User Jun 2, 2024 #2 Those commands do not have an "append" so what you would like to do is not possible. Who knows why you want everything to be in a single file or, better yet, what the problem is in having multiple files. You should probably use a SQLite file. Upvote 0
Those commands do not have an "append" so what you would like to do is not possible. Who knows why you want everything to be in a single file or, better yet, what the problem is in having multiple files. You should probably use a SQLite file.