Click here to Skip to main content
15,884,472 members
Articles / Programming Languages / C#

Laptop Backup

Rate me:
Please Sign up or sign in to vote.
4.45/5 (31 votes)
19 Jun 200517 min read 118.4K   4.6K   103  
A file backup system using remoting.
using System;
using System.Xml;
using SharpUtils;
using System.Management;
using System.IO;
using System.Text;

namespace LaptopCommunications
{
	/// <summary>
	/// Summary description for DiskData.
	/// </summary>
	[Serializable]
	public class DiskData
	{

		/// <summary>
		/// Log progess as u go
		/// </summary>
		private SimpleEventLog eventLog;

		/// <summary>
		/// control the amount of information written
		/// </summary>
		private DebugLevel debugLevel;


		/// <summary>
		/// Management class to start the disk data
		/// </summary>
		private ManagementClass diskClass;



		/// <summary>
		/// Get the management class
		/// </summary>
		public ManagementClass DiskInfo
		{
			get
			{
				return diskClass;
			}
		}


		public DiskData()
		{
			//
			// TODO: Add constructor logic here
			//

			/// create the event logging info
			debugLevel = new DebugLevel( DebugLevel.currentLevel );
			/// add to the existing event log not delete
			eventLog = new SimpleEventLog( "Laptop Backup", false );

			diskClass = new ManagementClass( "Win32_LogicalDisk" );

		}


		/// <summary>
		/// Getting the starting data for remote computer
		/// Drives
		/// </summary>
		/// <returns>true on success</returns>
		public ManagementClass StartData()
		{
			/// get the logical disks for this computer
			diskClass.Get();

			if( DebugLevel.currentLevel == DebugLevelSet.All )
			{
				eventLog.WriteInformation( "Getting the drive information" );
			}

			return diskClass;
		}


		/// <summary>
		/// Get the data from the passed in directory
		/// </summary>
		/// <param name="strFromDir">The directory to get the data for</param>
		/// <returns>true on success</returns>
		public DirectoryInfo GetData( string strFromDir )
		{
			StringBuilder buffer = new StringBuilder( strFromDir );
			if( buffer.Length == 2 ) /// a drive
			{
				buffer.Append( "\\" );
			}

			DirectoryInfo dirInfo = new DirectoryInfo( buffer.ToString() );

			return dirInfo;
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions