Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7564117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:50:08+00:00 2026-05-30T13:50:08+00:00

I need to unzip a file that is located in base directory, for example,

  • 0

I need to unzip a file that is located in base directory, for example, sample.zip. I have made A sample application for doing so. I have 1 input parameter – destination directory. Here are code samples:

private void BInstall_Click(object sender, EventArgs e)
{
    string currentdir = Directory.GetCurrentDirectory();//Gets current directory
    string zip = currentdir + "\\" + "sample.zip";//Path to zip file
    string outPath = TBoutputPath.Text;
    exctract(zip ,outPath );
}

And here is the function that is supposed to extract the zip file:

void exctract(string name, string path)
{
    string[] args = new string[2];
    if (name.IndexOf(" ") != -1)
    {
        //we got a space in the path so wrap it in double qoutes
        args[0] += "\"" + name + "\"";
    }
    else
    {
        args[0] += name;
    }

    if (path.IndexOf(" ") != -1)
    {
        //we got a space in the path so wrap it in double qoutes
        args[1] += " " + "\"" + path + "\"";
    }
    else
    {
        args[1] +=path;
    }

    Shell32.Shell sc = new Shell32.Shell(); 
    Shell32.Folder SrcFlder = sc.NameSpace(args[0]);
    Shell32.Folder DestFlder = sc.NameSpace(args[1]);
    Shell32.FolderItems items = SrcFlder.Items();
    DestFlder.CopyHere(items , 20); 
}

At DestFlder.CopyHere(items , 20); I get NullReferenceException, and I don’t know why, since the objects shouldn’t be null. It is DestFlder that is null; it seems that SrcFolder is initialized but DestFlder is not. The only difference I can find is that DestFlder doesn’t have a file extension following, but since it is a folder, it shouldn’t have one anyway.

Can anyone explain me what I did wrong and how to fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:50:09+00:00Added an answer on May 30, 2026 at 1:50 pm

    The answer to this problem was rather… trivial, but as all of the simplest problems, next to impossible to think of.

    The folder did not exist and therefor could not be referenced to. This code piece fixed that:

            if (!Directory.Exists(args[1]))
                Directory.CreateDirectory(args[1]);
    

    Thou DJ KRAZE did point to another problem with the script that could have it possibly get a run-time error eventually. Thank you for that!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm uploading ZIP file to Amazon S3. Now I need to unzip that file
In my application, I need to Zip and Unzip some files. For that I
I have a gz file that is about 100 GB, I need to split
We need to untar/unzip a very large archive file on a server that we
I want to uncompress zipped file say, files.zip , to a directory that is
I need to download and unzip a sitemap.xml file that is compressed (maybe tar
I need a zip library (or a function) that can zip\unzip a few files,
I have a program written in python that uploads an archive (zip file) to
I have a nice java code that unzips a .zip file. But problem with
I need to unzip file synced through itunes in the documents directory programmatically. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.