Using a memory profile on my C# desktop app I have found that strings are not being released from memory causing a slow and gradual buildup.
I have this code:
var ToYYYMMDDHHMMSS = "YYYMMDDHHMMSS";
var toYR = ToYYYMMDDHHMMSS.Substring(0, 4);
var toMN = ToYYYMMDDHHMMSS.Substring(4, 2);
var toDY =ToYYYMMDDHHMMSS.Substring(6, 2);
var toHR = ToYYYMMDDHHMMSS.Substring(8, 2);
var toMI = ToYYYMMDDHHMMSS.Substring(10, 2);
var motionPath = string.Format("{0}\\Catalogues\\{1}\\{2}\\{3}\\{4}\\{5}\\{6}", Shared.MOTION_DIRECTORY, camIndex, toYR, toMN, toDY, toHR, toMI);
Is there an alternative to using the substring? Can I use String.Format someway to get my desired result?
NB I am so sorry for my poor phrasing of my question..
var ToYYYMMDDHHMMSS = "YYYMMDDHHMMSS";
I should have added that "YYYMMDDHHMMSS" is a timestamp that always changes {apologies)
DateTimevalue, formatted asyyyyMMddHHMMss? If so, I'd suggest parsing it as aDateTime- that'll make everything much simpler.ToYYYMMDDHHMMSSis constant, thus all yourto*can be precalculated, and lots of the path parameters are fixed.