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 6334011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:34:36+00:00 2026-05-24T18:34:36+00:00

I want to upload an entire folder keeping the same structure (folder, subfolders..) to

  • 0

I want to upload an entire folder keeping the same structure (folder, subfolders..) to a remote server. It´s necessary to iterate all folder or is possible to get the folder and upload to the server ?

I can upload single files but I think that the strategy with the folders maybe (sure) is different.

Any suggestion?

Thanks

EDIT: Is a remote server

  • 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-24T18:34:37+00:00Added an answer on May 24, 2026 at 6:34 pm

    I’m not sure this is what you are looking for, but sometimes it might be easier to upload the zipped folder (with low compression level) and unpack it on the server, if you can manage this on a client side. If it is applicable for you you might use free .net zip library like the SharpZipLib, so you don’t have to write the zipping routine by yourself.

    Here is also the class for zipping/unzipping folders using thr SharZipLib:

    using System;
    using System.Collections;
    using System.IO;
    using ICSharpCode.SharpZipLib.Zip;
    
    namespace ENSI.Releaser.Code
    {
        public class ZipUtility
        {
            public void ZipFiles(string inputFolderPath, string outputPathAndFile, string     password)
        {
            ArrayList ar = GenerateFileList(inputFolderPath); // generate file list
            int trimLength = (Directory.GetParent(inputFolderPath)).ToString().Length;
            // find number of chars to remove     // from orginal file path
            trimLength += 1; //remove '\'
            FileStream ostream;
            byte[] obuffer;
            string outPath = inputFolderPath + @"\" + outputPathAndFile;
            var oZipStream = new ZipOutputStream(File.Create(outPath)); // create zip stream
            if (!string.IsNullOrEmpty(password))
                oZipStream.Password = password;
            oZipStream.SetLevel(9); // maximum compression
            ZipEntry oZipEntry;
            foreach (string fil in ar) // for each file, generate a zipentry
            {
                oZipEntry = new ZipEntry(fil.Remove(0, trimLength));
                oZipStream.PutNextEntry(oZipEntry);
    
                if (!fil.EndsWith(@"/")) // if a file ends with '/' its a directory
                {
                    ostream = File.OpenRead(fil);
                    obuffer = new byte[ostream.Length];
                    ostream.Read(obuffer, 0, obuffer.Length);
                    oZipStream.Write(obuffer, 0, obuffer.Length);
                }
            }
            oZipStream.Finish();
            oZipStream.Close();
        }
    
        private ArrayList GenerateFileList(string dir)
        {
            var fils = new ArrayList();
            bool Empty = true;
            foreach (string file in Directory.GetFiles(dir)) // add each file in directory
            {
                fils.Add(file);
                Empty = false;
            }
    
            if (Empty)
            {
                if (Directory.GetDirectories(dir).Length == 0)
                // if directory is completely empty, add it
                {
                    fils.Add(dir + @"/");
                }
            }
    
            foreach (string dirs in Directory.GetDirectories(dir)) // recursive
            {
                foreach (object obj in GenerateFileList(dirs))
                {
                    fils.Add(obj);
                }
            }
            return fils; // return file list
        }
    
        public void UnZipFiles(string zipPathAndFile, string outputFolder, string password, bool deleteZipFile)
        {
            var s = new ZipInputStream(File.OpenRead(zipPathAndFile));
            if (!string.IsNullOrEmpty(password))
                s.Password = password;
            ZipEntry theEntry;
            string tmpEntry = String.Empty;
            while ((theEntry = s.GetNextEntry()) != null)
            {
                string directoryName = outputFolder;
                string fileName = Path.GetFileName(theEntry.Name);
                // create directory 
                if (directoryName != "")
                {
                    Directory.CreateDirectory(directoryName);
                }
                if (fileName != String.Empty)
                {
                    if (theEntry.Name.IndexOf(".ini") < 0)
                    {
                        string fullPath = directoryName + "\\" + theEntry.Name;
                        fullPath = fullPath.Replace("\\ ", "\\");
                        string fullDirPath = Path.GetDirectoryName(fullPath);
                        if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
                        FileStream streamWriter = File.Create(fullPath);
                        int size = 2048;
                        byte[] data = new byte[size];
                        while (true)
                        {
                            size = s.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                streamWriter.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                        streamWriter.Close();
                    }
                }
            }
            s.Close();
            if (deleteZipFile)
                File.Delete(zipPathAndFile);
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upload a list of users from my work's LDAP server to
i want to upload the sound file (.ogg) in server. But it should write
I want to upload and store video files to my server using PHP. Could
I want to upload a file to a ftp server programmatically (C++). If the
I want to 301 redirect an entire website, but exclude everything in a folder
I want to do a file upload without posting an entire form. The file
I want to upload a particular file on server in Silverlight 4, Simply, to
I want to upload a file to net server use the codes. but when
I want to upload and then process a file in a Ruby on Rails
I want to upload upload up to 100 MB to 1GB file onto sharepoint

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.