Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
added config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
pouyakary committed Mar 9, 2016
1 parent f833dac commit fec9291
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Note/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class MainClass
// ─── CONST STUFF ────────────────────────────────────────────────────────────────────────────────────
//

static readonly string note_file_address = "/users/pmk/Dropbox (personal)/.KaryAppData/notes.txt";
static string note_file_address;
static readonly string note_file_address_config_file = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Personal ), ".notepath" );
static readonly string astrisk_with_space = " ✣ ";

//
Expand All @@ -38,6 +39,22 @@ public static int max_roman_size ( int max_number ) {
}
return max_size;
}

//
// ─── CONFIG FILE LOADER ─────────────────────────────────────────────────────────────────────────────
//

public static bool LoadPathAddress ( ) {
try {
using( StreamReader reader = new StreamReader( note_file_address_config_file ) ) {
note_file_address = reader.ReadToEnd( ).Trim( );
}
return true;
} catch {
Report( "Could not load the config file." );
return false;
}
}

//
// ─── PRINT FOOTER ───────────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -400,6 +417,19 @@ public static void Report ( string message ) {
//

public static void Main ( string[ ] args ) {

//
// LOADING CONFIG FILE
//

if ( !LoadPathAddress( ) ) {
return;
}


//
// PARSING THE ARGUMENTS
//

if ( args.Length == 0 ) {

Expand Down

0 comments on commit fec9291

Please sign in to comment.