Click here to Skip to main content
13,096,858 members (76,436 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 11 Aug 2004

ASP.NET Deployment App

, 17 Aug 2004
Rate this:
Please Sign up or sign in to vote.
How I created an application to help exclude the many files needed to deploy a DotNetNuke site


I just became engrossed with the DotNetNuke Framework and have made a number of new modules to try out, but when it came time to upload the app -- provided I uploaded it all, it was over 60 Megs. That's a lot of time and transfer just for a bunch of unnecessary files. The best advice I had to strip out the unwanted files was to Search for them (in a copy) and delete them -- ONE PASS FOR EACH FILE. This was not going to do.

I did find another app that did what this one does with some extra features for zipping and ftping, but I was just looking for something to copy only the selected files and the existing folder structure to a new folder and I could deal with getting them up on the server myself.

The only snag in my plan was I didn't know exactly what file types were needed to fully support a DNN site. So I made the app scan the source folder for all the possible file extensions and then allow the user to uncheck the ones that shouldn't make the trip.

I didn't see anything else (besides the one mentioned earlier) that did this, so I thought I'd post it here for all to download.

Using the code

This is a very small little app -- only 7 methods. Let's get started.

Folder Browsing

First I needed a FolderBrowser Dialog (something I sorely missed with .net 1.0). Note the use of the Description attribute. Give the user something to read on the box.

private void btnSource_Click(object sender, System.EventArgs e)
  folderBrowserDialog1.Description = 
    "Choose the Source Location to copy files from.";
  DialogResult result = folderBrowserDialog1.ShowDialog();
  if( result == DialogResult.OK )
    tboxSource.Text = folderBrowserDialog1.SelectedPath;
private void btnDestination_Click(object sender, System.EventArgs e)
  folderBrowserDialog1.Description = 
    "Choose the Destination Location to copy files to.";
  DialogResult result = folderBrowserDialog1.ShowDialog();
  if( result == DialogResult.OK )
    tboxDestination.Text = folderBrowserDialog1.SelectedPath;

I use a couple of textboxes to store the result -- or allow the user to just type them in.

Folder Checking

This routine, given a source and destination DirectoryInfo objects, iterates through the subfolders in the source and reiteratively calls itself to repeat the process, either making copies of all the folders and their subfolders if the site is being copied, or just allows the CheckFiles method to scan the files, but I get ahead of myself.

private void CheckDirectories(DirectoryInfo source, 
  DirectoryInfo destination, bool Deploy)
  foreach (DirectoryInfo tempdir in source.GetDirectories())
    if (Deploy)
      tboxCopiedFiles.Text += "Creating Folder " + 
       destination.FullName + "\\" + tempdir.Name + "\r\n";
    DirectoryInfo tSource = new DirectoryInfo(
      source.FullName + "\\" + tempdir.Name);
    DirectoryInfo tDestin = new DirectoryInfo(
      destination.FullName + "\\" + tempdir.Name);
    CheckDirectories(tSource, tDestin, Deploy);
    CheckFiles(tSource, tDestin, Deploy);

File Checking

This next section either loads up the lboxExtensions listbox or actually does the file copying. It's simply a matter of making a FileInfo object for each thing the the directory and parsing out the extension or copying it to the destination.

private void CheckFiles(DirectoryInfo source, 
   DirectoryInfo destination, bool Deploy)
  string extension = "";
  foreach (FileInfo tempfile in source.GetFiles())
    extension = tempfile.Extension.ToLower();
    if (Deploy)
      foreach (string item in lboxExtensions.CheckedItems)
        if (item == extension)
          tempfile.CopyTo(destination.FullName + "\\" + tempfile.Name, true);
          tboxCopiedFiles.Text += "Copying file " + tempfile.Name + "\r\n";
      if (!lboxExtensions.Items.Contains(extension))
        lboxExtensions.Items.Add(extension, true);


I reused the Directory/File checking methods for both the scanning and the copying. I pass it the boolean mDeploy to control their behavior.

Button Clicking

I probably could have wrapped these into one EventHandler but -- I didn't do it. Sorry. A victim of RAD.

Pretty straight forward code here. Just a call to start the process (next -- finally!) and for working the ProgressBar.

private void btnDeploy_Click(object sender, System.EventArgs e)
  progressBar1.Minimum = 0;
  progressBar1.Maximum = folderCount;
  tboxCopiedFiles.Text += "Folders created: " +
    folderCount.ToString() + "\r\n";
  tboxCopiedFiles.Text += "Files copied: " + fileCount.ToString();
  progressBar1.Value = 0;

private void btnScan_Click(object sender, System.EventArgs e)
  lboxExtensions.Sorted = true;
  this.btnDeploy.Enabled = true;

The Starting Point

I made this routine to be outside the reiterative process as a place to either start the Scan or the Deployment. It sets the button Enabling and kicks it all off. It also allows for one place for the try/catch block to be set. This method accepts the boolean mDeploy and passes that to the other methods.

private void StartProcessing(bool mDeploy)
  this.btnDeploy.Enabled = false;
  this.btnScan.Enabled = false;
  tboxCopiedFiles.Text = "";
    DirectoryInfo srce = new DirectoryInfo(tboxSource.Text);
    DirectoryInfo dest = new DirectoryInfo(tboxDestination.Text);
    CheckDirectories(srce, dest, mDeploy);
    CheckFiles(srce, dest, mDeploy
  catch (Exception ex)
    MessageBox.Show("I/O Error", "Did you choose your folders?",
  if (this.lboxExtensions.Items.Count > 0)
    this.btnDeploy.Enabled = true;
  this.btnScan.Enabled = true;

Points of Interest

All in all a quick and easy project. Allowing me not to move fewer files up -- though I would still like to know exactly what files are needed. Emails on that subject are welcomed. This could easily be employed for a non-Website publishing purposes, but that's what I needed it for.


  • Version 1.0 completed : 8.9.2004


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions deployment...javascript errrors Pin
Manish Thapak3-Oct-07 5:29
memberManish Thapak3-Oct-07 5:29 
GeneralModule deployment Pin
Russel Harvey1-Sep-04 12:15
memberRussel Harvey1-Sep-04 12:15 
GeneralRe: Module deployment Pin
bob_dotnet2-Sep-04 1:12
sussbob_dotnet2-Sep-04 1:12 
GeneralNice job, but... Pin
attackweasel18-Aug-04 9:27
memberattackweasel18-Aug-04 9:27 
GeneralRe: Nice job, but... Pin
bob_dotnet18-Aug-04 9:37
sussbob_dotnet18-Aug-04 9:37 
GeneralRe: Nice job, but... Pin
attackweasel18-Aug-04 9:57
memberattackweasel18-Aug-04 9:57 
GeneralModified Date Suggestion Pin
Trashken17-Aug-04 23:31
memberTrashken17-Aug-04 23:31 
I wrote a DOS batch file which I use frequently to extract the files that is required for a deployment and have always wanted a windows based solution. This app would be perfect if it had a feature that would only extract files that has been modified within a date range specified by the user. That would save space for those times when the application has already been deployed and you only want to grab the files modified today and update the production version.

A side feature request would be to be able to save the files to be included into a sort of profile so users don't have to select which files to exclude everytime they run the deployment app. Big Grin | :-D
GeneralRe: Modified Date Suggestion Pin
bob_dotnet18-Aug-04 1:19
sussbob_dotnet18-Aug-04 1:19 
GeneralSmall bug and a suggestion Pin
Stephane Lajoie14-Aug-04 15:48
memberStephane Lajoie14-Aug-04 15:48 
GeneralRe: Small bug and a suggestion Pin
bob_dotnet16-Aug-04 1:22
memberbob_dotnet16-Aug-04 1:22 
GeneralRe: Small bug and a suggestion Pin
Stephane Lajoie16-Aug-04 2:08
memberStephane Lajoie16-Aug-04 2:08 
GeneralRe: Small bug and a suggestion Pin
bob_dotnet16-Aug-04 2:14
sussbob_dotnet16-Aug-04 2:14 
QuestionExtensions to deploy? Pin
zoomba12-Aug-04 10:00
memberzoomba12-Aug-04 10:00 
AnswerRe: Extensions to deploy? Pin
bob_dotnet13-Aug-04 4:07
sussbob_dotnet13-Aug-04 4:07 
GeneralRe: Extensions to deploy? Pin
zoomba13-Aug-04 6:19
memberzoomba13-Aug-04 6:19 
GeneralRe: Extensions to deploy? Pin
tkraak8-Jan-05 7:01
membertkraak8-Jan-05 7:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 18 Aug 2004
Article Copyright 2004 by bob_dotnet
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid