Click here to Skip to main content
15,890,282 members
Home / Discussions / C#
   

C#

 
AnswerRe: creating a folder on console application with c# by clicking on it's .exe file ! Pin
BillWoodruff17-Jun-16 23:45
professionalBillWoodruff17-Jun-16 23:45 
QuestionHow to export a result table and charts from RDotNet to Excel Pin
Member 1085025317-Jun-16 15:45
Member 1085025317-Jun-16 15:45 
AnswerRe: How to export a result table and charts from RDotNet to Excel Pin
Garth J Lancaster17-Jun-16 16:40
professionalGarth J Lancaster17-Jun-16 16:40 
GeneralRe: How to export a result table and charts from RDotNet to Excel Pin
Member 1085025323-Jun-16 11:41
Member 1085025323-Jun-16 11:41 
GeneralRe: How to export a result table and charts from RDotNet to Excel Pin
Garth J Lancaster23-Jun-16 16:12
professionalGarth J Lancaster23-Jun-16 16:12 
GeneralRe: How to export a result table and charts from RDotNet to Excel Pin
Member 1085025323-Jun-16 16:22
Member 1085025323-Jun-16 16:22 
QuestionCan't get the replace to work, and double check my work. Pin
jkirkerx17-Jun-16 11:11
professionaljkirkerx17-Jun-16 11:11 
AnswerMy Bad, perhaps I can just get that double check Pin
jkirkerx17-Jun-16 11:19
professionaljkirkerx17-Jun-16 11:19 
I don't enough sleep on Thursday nights. Say I have a question, do you think this new version is the equiv to the old version below? Functionally the same except for the linefeed detector?
private static string read_HTML_Template(
            model_crm_contact_request cm)
        {
            string html_Template = string.Empty;
            using (var htmlStream = new FileStream(cm.smtp_templatePath_customer, FileMode.Open, FileAccess.Read))
            {
                long htmlLen = htmlStream.Length;
                byte[] bytes = new byte[htmlLen];
                htmlStream.Read(bytes, 0, (int)htmlLen);

                if (!(htmlStream == null))
                    htmlStream.Close();

                var enc = new UTF8Encoding(true);
                var preamble = enc.GetPreamble();
                if (preamble.Where((p, i) => p != bytes[i]).Any())
                    html_Template = enc.GetString(bytes.ToArray());
                else
                    html_Template = enc.GetString(bytes.Skip(preamble.Length).ToArray());

            }

            html_Template = html_Template.Replace("<% smtp.WebsiteUrl %>", cm.smtp_websiteUrl);
            html_Template = html_Template.Replace("<% smtp.HeaderImage %>", cm.smtp_headerImage);
            html_Template = html_Template.Replace("<% smtp.CustomerName %>", cm.Name);
            html_Template = html_Template.Replace("<% smtp.WebsiteName %>", cm.smtp_websiteName);
            html_Template = html_Template.Replace("<% smtp.CustomerComment %>", cm.Query);

            html_Template = html_Template.Replace("<% smtp.TimeStamp_GMT %>", DateTime.UtcNow + " GMT");
            html_Template = html_Template.Replace("<% smtp.TimeStamp_UTC %>", DateTime.UtcNow + " UTC");

            return html_Template;

        }        

This is the old version
private static string read_HTML_Template(
            model_crm_contact_request cm)
        {
            FileStream htmlStream = null;

            htmlStream = new FileStream(cm.smtp_templatePath_website, FileMode.Open, FileAccess.Read);
            long htmlLen = htmlStream.Length;
            byte[] fileData = new byte[htmlLen];
            htmlStream.Read(fileData, 0, (int)htmlLen);
            if (!(htmlStream == null))
                htmlStream.Close();

            byte[] byteLine = new byte[0];
            string[] strArray = new string[0];
            for (int bdx = 0; (bdx
                        <= (fileData.Length - 1)); bdx++)
            {
                byte byteVal = fileData[bdx];
                if (!(byteVal == 13))
                {
                    Array.Resize(ref byteLine, byteLine.Length + 1);
                    byteLine[byteLine.Length - 1] = byteVal;
                }
                else
                {
                    Array.Resize(ref byteLine, byteLine.Length + 1);
                    byteLine[byteLine.Length - 1] = byteVal;
                    char[] charLine = new char[0];
                    Array.Resize(ref charLine, byteLine.Length + 1);
                    for (int cdx = 0; (cdx <= (byteLine.Length - 1)); cdx++)
                    {
                        charLine[cdx] = AsciiByteToChar(byteLine[cdx]);
                    }
                    string value = new string(charLine);
                    Array.Resize(ref strArray, strArray.Length + 1);
                    strArray[strArray.Length - 1] = value;
                    Array.Resize(ref byteLine, 0);
                    bdx++;
                }
            }
            // //////////////////////////////////////////////////////////////////
            //  Remove the BOM Marker - When we use Gulp to copy from Assets, the bom marker is removed
            //strArray[0] = strArray[0].Substring((strArray[0].Length - (strArray[0].Length - 3)));
            // //////////////////////////////////////////////////////////////////
            StringBuilder html_Template = new StringBuilder();
            for (int idx = 0; (idx <= (strArray.Length - 1)); idx++)
            {
                // //////////////////////////////////////////////////////////
                // Convert the Tab Character to Html<br />
                int integerRead = 0;
                char characterRead;
                StringBuilder htmlBuilder = new StringBuilder();
                StringReader charReader = new StringReader(strArray[idx]);
                while (true)
                {
                    integerRead = charReader.Read();
                    if ((integerRead == -1))
                    {
                        break; //Warning!!! Review that break works as 'Exit Do' as it could be in a nested instruction like switch
                    }
                    characterRead = Convert.ToChar(integerRead);
                    if ((characterRead == '\t'))
                    {

                    }
                    else if (((characterRead == '\r') || (characterRead == '\n')))
                    {

                    }
                    else
                    {
                        htmlBuilder.Append(characterRead);
                    }
                }
                string htmlString = htmlBuilder.ToString();
                htmlString = htmlString.Substring(0, (htmlString.Length - 1));
                html_Template.Append(htmlString);
            }

            html_Template.Replace("<% smtp.WebsiteUrl %>", cm.smtp_websiteUrl);
            html_Template.Replace("<% smtp.HeaderImage %>", cm.smtp_headerImage);
            html_Template.Replace("<% smtp.CustomerName %>", cm.Name);
            html_Template.Replace("<% smtp.WebsiteName %>", cm.smtp_websiteName);
            html_Template.Replace("<% smtp.CustomerComment %>", cm.Query);

            html_Template.Replace("<% smtp.TimeStamp_GMT %>", DateTime.UtcNow + " GMT");
            html_Template.Replace("<% smtp.TimeStamp_UTC %>", DateTime.UtcNow + " UTC");

            return html_Template.ToString();

        }

QuestionError while trying to use R.Net in VS 2012 Pin
Member 1085025317-Jun-16 5:39
Member 1085025317-Jun-16 5:39 
AnswerRe: Error while trying to use R.Net in VS 2012 Pin
OriginalGriff17-Jun-16 5:47
mveOriginalGriff17-Jun-16 5:47 
QuestionHelp me gather info about multiple monitors Pin
Tomaž Štih17-Jun-16 3:41
Tomaž Štih17-Jun-16 3:41 
AnswerRe: Help me gather info about multiple monitors Pin
BillWoodruff17-Jun-16 23:52
professionalBillWoodruff17-Jun-16 23:52 
GeneralRe: Help me gather info about multiple monitors Pin
Tomaž Štih18-Jun-16 3:52
Tomaž Štih18-Jun-16 3:52 
GeneralRe: Help me gather info about multiple monitors Pin
BillWoodruff18-Jun-16 19:06
professionalBillWoodruff18-Jun-16 19:06 
QuestionI want to show my GPS cursor in Mapwingis, how to do it? Pin
Member 1241411416-Jun-16 3:55
Member 1241411416-Jun-16 3:55 
AnswerRe: I want to show my GPS cursor in Mapwingis, how to do it? Pin
Pete O'Hanlon16-Jun-16 21:40
mvePete O'Hanlon16-Jun-16 21:40 
GeneralRe: I want to show my GPS cursor in Mapwingis, how to do it? Pin
Member 1241411416-Jun-16 22:32
Member 1241411416-Jun-16 22:32 
GeneralRe: I want to show my GPS cursor in Mapwingis, how to do it? Pin
Pete O'Hanlon16-Jun-16 22:37
mvePete O'Hanlon16-Jun-16 22:37 
GeneralRe: I want to show my GPS cursor in Mapwingis, how to do it? Pin
Member 1241411416-Jun-16 22:40
Member 1241411416-Jun-16 22:40 
GeneralRe: I want to show my GPS cursor in Mapwingis, how to do it? Pin
Pete O'Hanlon16-Jun-16 22:45
mvePete O'Hanlon16-Jun-16 22:45 
QuestionHow to find out, if the toolbar icon or the notifyicon is clicked Pin
Member 1191673515-Jun-16 19:26
Member 1191673515-Jun-16 19:26 
AnswerRe: How to find out, if the toolbar icon or the notifyicon is clicked Pin
OriginalGriff15-Jun-16 20:22
mveOriginalGriff15-Jun-16 20:22 
GeneralRe: How to find out, if the toolbar icon or the notifyicon is clicked Pin
Member 1191673515-Jun-16 22:50
Member 1191673515-Jun-16 22:50 
GeneralRe: How to find out, if the toolbar icon or the notifyicon is clicked Pin
OriginalGriff15-Jun-16 22:53
mveOriginalGriff15-Jun-16 22:53 
QuestionAccess Gmail contacts through C # Pin
Member 1253942914-Jun-16 14:42
Member 1253942914-Jun-16 14:42 

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.