private void ProcessLine(StreamReader sr, string s, ref ConfigurationValues confValues, ref string err)
        {
            string key = string.Empty;
            StringBuilder sb = new StringBuilder();

            try
            {
                if (s != string.Empty && s.Trim().IndexOf(COMMENT_CHAR) != 0)
                {
                    string str = s.Trim();
                    string r = string.Empty;

                    if (str.LastIndexOf(LINE_CONTINUATION) != str.Length - LINE_CONTINUATION.Length)
                    {
                        string[] pair = str.Split('=');
                        r = ProcessNameValuePair(pair, ref confValues);
                    }
                    else
                    {
                        string command = string.Empty;
                        string value = string.Empty;

                        str = str.Substring(0, str.Length - LINE_CONTINUATION.Length);
                        command = str.Substring(0, str.IndexOf('=') - 1).Trim();
                        value = str.Substring(str.IndexOf('=') + 1, str.Length - str.IndexOf('=') - 1).Trim();
                        if (value != string.Empty) value += ";";

                        string nextLine = string.Empty;
                        bool lineContinuation = false;

                        do
                        {
                            nextLine = sr.ReadLine();
                            lineContinuation = nextLine.LastIndexOf(LINE_CONTINUATION) == nextLine.Length - LINE_CONTINUATION.Length;
                            if (lineContinuation)
                            {
                                value += nextLine.Substring(0, nextLine.Length - LINE_CONTINUATION.Length - 1).Trim();
                                value += ";";
                            }
                        } while (lineContinuation);
                        value += nextLine.Trim();
                        r = ProcessNameValuePair(new string[] {command, value}, ref confValues);
                    }
                    if (r != string.Empty) sb.AppendLine(r);
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine(ex.ToString());
            }

            err = sb.ToString();
        }
        public ConfigurationValues GetConfigurations(string fileName, ref string err)
        {
            ConfigurationValues confValues = new ConfigurationValues();
            confValues.SrcDir = Environment.CurrentDirectory;
            confValues.DestDir = Environment.CurrentDirectory;
            confValues.OutputFile = string.Concat(Guid.NewGuid().ToString("N"), ".tiff");

            StreamReader sr = new StreamReader(fileName);

            string s = string.Empty;
            err = string.Empty;
            string lastLine = string.Empty;
            do
            {
                s = sr.ReadLine();
                if (s != null && s.Trim() != string.Empty)
                    ProcessLine(sr, s, ref confValues, ref err);
            } while (s != null);

            sr.Close();

            return confValues;
        }
        private string ProcessNameValuePair(string[] pair, ref ConfigurationValues confValues)
        {
            string r = string.Empty;

            switch (pair[0].Trim().ToUpper())
            {
                case "ACTION":
                    confValues.Action = RemoveLineComment(pair[1].Trim());
                    break;
                case "SOURCE_DIR":
                    confValues.SrcDir = RemoveLineComment(pair[1].Trim());
                    break;
                case "DESTINATION_DIR":
                    confValues.DestDir = RemoveLineComment(pair[1].Trim());
                    break;
                case "INPUT":
                    confValues.InputFiles = RemoveLineComment(pair[1].Trim());
                    break;
                case "OUTPUT":
                    confValues.OutputFile = RemoveLineComment(pair[1].Trim());
                    break;
                default:
                    r = string.Format("*** ERROR ***: Key {0} not recognized.", pair[0]);
                    break;
            }

            return r;
        }