2014-06-29 22:04:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace SCJMapper_V2
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides some items that are user related - packed in one place..
|
|
|
|
|
/// </summary>
|
|
|
|
|
class TheUser
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
2014-06-29 22:04:27 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the name of the Personal Program folder in My Documents
|
|
|
|
|
/// Creates the folder if needed
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Path to the Personal Program directory</returns>
|
|
|
|
|
static public String UserDir
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "UserDir - Entry" );
|
2014-06-29 22:04:27 +00:00
|
|
|
|
String docPath = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.Personal ), Application.ProductName);
|
|
|
|
|
if ( !Directory.Exists( docPath ) ) Directory.CreateDirectory( docPath );
|
|
|
|
|
return docPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the mapping file name + path into our user dir
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mapName">The mapping name</param>
|
|
|
|
|
/// <returns>A fully qualified filename</returns>
|
|
|
|
|
static public String MappingFileName( String mapName )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "MappingFileName - Entry" );
|
|
|
|
|
|
2014-06-29 22:04:27 +00:00
|
|
|
|
return Path.Combine( UserDir, mapName + ".xml" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-08-31 13:05:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a backupfile from the given file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mapName">The mapping name</param>
|
|
|
|
|
static public void BackupMappingFile( String mapName )
|
|
|
|
|
{
|
|
|
|
|
log.Debug( "BackupMappingFile - Entry" );
|
|
|
|
|
|
|
|
|
|
String mf = MappingFileName( mapName );
|
|
|
|
|
if ( File.Exists( mf ) ) File.Copy( mf, mf + ".backup", true );
|
|
|
|
|
}
|
2014-06-29 22:04:27 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|