-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to save FileSystem changes to disk? #81
Comments
|
Yes, you are right, after I called zipFs.Dispose(), the changes were saved to the disk. But another question, if I want to modify it repeatedly and then save it repeatedly, I need to call Dispose() and then reread the local file. like this: using Zio;
using Zio.FileSystems;
namespace ZioTest;
internal class ZipCreator
{
private ZipArchiveFileSystem _zipFs;
public void CreateZip(int index)
{
var path = Environment.CurrentDirectory;
//Console.WriteLine(path);
_zipFs = new ZipArchiveFileSystem($"{path}/test1.zip");
_zipFs.CreateDirectory($"/test{index}");
_zipFs.WriteAllText($"/test{index}/test.txt", "Hello World");
}
public void Close()
{
_zipFs.Dispose();
}
}
public class Program
{
public static void Main(string[] args)
{
ZipCreator creator = new();
creator.CreateZip(1);
creator.Close();
creator.CreateZip(2);
creator.Close();
}
} These operations seems not very good for larger files. Is there any way to save changes manually like the belowing code: using Zio;
using Zio.FileSystems;
namespace ZioTest;
internal class ZipCreator
{
private ZipArchiveFileSystem _zipFs;
public void CreateZip()
{
var path = Environment.CurrentDirectory;
//Console.WriteLine(path);
_zipFs = new ZipArchiveFileSystem($"{path}/test1.zip");
}
public void MakeContents(int index)
{
_zipFs.CreateDirectory($"/test{index}");
_zipFs.WriteAllText($"/test{index}/test.txt", "Hello World");
}
public void PersistenceToDisk()
{
_zipFs.FlushToDisk(); // Is there any method to save the zip file without closing the file system?
}
public void Close()
{
_zipFs.Dispose();
}
}
public class Program
{
public static void Main(string[] args)
{
ZipCreator creator = new();
creator.CreateZip();
creator.MakeContents(1);
creator.PersistenceToDisk();
creator.MakeContents(2);
creator.Close();
}
} |
I see the ZipArchiveFileSystem.Dispose() called ZipArchive.Dispose(). So it should be ZipArchive.Dispose() that save its changes to disk. But I found that ZipArchive dosen't have a method to save itself unless call dispose. |
I think this is blocked by dotnet/runtime#24149 |
I have used the ZipArchiveFileSystem to create a zip file on disk. And then I add some directory and files. But how can I save these modifications to disk?
I use the code below:
After I run the code, I got the zip file "test1.zip", but it's size is zero.
I have read the document and not found any information about save a FileSystem to disk.
dotnet version: 7.0
zio version: 0.17.0
The text was updated successfully, but these errors were encountered: