---
title: "packa upp fil på servern"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/167761-packa-upp-fil-på-servern"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Vinnaren"
published: "2008-01-03T18:34:09.000Z"
updated: "2008-01-03T18:52:44.000Z"
replies: 1
views: 490
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/167761-packa-upp-fil-på-servern"
---

# packa upp fil på servern

## #1 — Vinnaren, 2008-01-03T18:34Z

Har koden:

```
    protected void Unzipfile(string sfile)
    {

        ZipInputStream s = new ZipInputStream(File.OpenRead(sfile));
        ZipEntry theEntry = new ZipEntry(sfile);
        DirectoryInfo di = new DirectoryInfo(GetFolderPath());

        if (!di.Exists)
        {
            di.Create();
        }

            string directoryName = Path.GetDirectoryName(theEntry.Name);
            string fileName = Path.GetFileName(theEntry.Name);
            
            if (theEntry.IsDirectory)
            {
                Directory.CreateDirectory(di.ToString() + directoryName);
            }

            if (fileName != String.Empty)
            {
                String orginalPath = tvMap.SelectedNode.ValuePath;

                //String url = Path.GetFullPath(sfile).ToString();
                //url = url.Replace(".rar", "").Replace(".zip", "");

                String UnZipUrl = orginalPath + "\\" + Path.GetFileNameWithoutExtension(sfile);

                if (!Directory.Exists(UnZipUrl))
                {
                    Directory.CreateDirectory(UnZipUrl);
                }

                FastZip fz = new FastZip();
                fz.ExtractZip(sfile, UnZipUrl, "");
            }
        
        s.Close();
        BindGrid();
        lblMsg.Text = "klart";

    }
```

 

Får felmeddelandet:
Cannot find central directory
på:

```
fz.ExtractZip(sfile, UnZipUrl, "");
```

sfile har värdet: C:\\\\....\\\\upload\\\\/tema\\\\test.rar
UnZipUrl har värdet: C:\\\\....\\\\upload\\\\/tema\\\\test

mappen test skapas ju innan, men inga filer packas upp.

Hur kan man lösa detta??

Tacksam för all hjälp   :stud

Permalänk: https://www.webforum.nu/p/167761

## #2 — Peter S, 2008-01-03T18:52Z

Är du säker på att ZipInputStream hanterar rar-filer?

Permalänk: https://www.webforum.nu/p/2067751

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/167761-packa-upp-fil-på-servern
