I'm trying to extract a zip file to a location and I get the following error:

System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'D:\test\Server\project\test.edb\Article.eod'.'

I'm running VS Studio with Administrator rights. The source file exists and the relative path seem correct on debugging. The actual zip file contains folders and files within folders, I'm not sure if that is the cause to the problem.

string zipPath = @".\..\..\assets\project.zip";
string projectPath = @".\..\..\project";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
    foreach(ZipArchiveEntry entry in archive.Entries)
    {
        String fullPath = Path.Combine(projectPath, entry.FullName);
        if (String.IsNullOrEmpty(entry.Name))
        {
            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
        }
        entry.ExtractToFile(fullPath, true);
    }
}

Related posts

Recent Viewed