["$ file..G$ ","|date as filename$filename property$","HYVXKVVusing System;Vusing System.IO;VVclass ProgramV{VHstatic KDates and required filenamesKVVDate:HHH 11/18/2008 5:04:44 PMVRequired filename: text-2008-11-18_05-04-44-PM.binVVDate:HHH 11/23/2004 12:05:47 AMVRequired filename: text-2004-11-23-12_05-47-AM.binKYvoid Main()VH{KVHH//VHH// Write file containing the date with BIN extensionVHH//VHHKstring n = string.Format(KXtext-{0:yyyy-MM-dd_hh-mm-ss-tt}.binXK,VHHHDateTime.Now);VHHFile.WriteAllText(n, XaaaX);VH}V}VVKDescription of format stringKVVXtext-{0:yyyy-MM-dd_hh-mm-ss-tt}.binXVVtext-H The first part of the output requiredVHH Files will all start with text-V{0:HHIndicates that this is a string placeholderVHH The zero indicates the index of the parameters inserted hereVyyyy-H Prints the year in four digits followed by a dashVHH This has a Xyear 10000X problemVMM-HHPrints the month in two digitsVdd_HHPrints the day in two digits followed by an underscoreVhh-HHPrints the hour in two digitsVmm-HHPrints the minute, also in two digitsVss-HHAs expected, it prints the secondsVttHH Prints AM or PM depending on the time of dayKYstring SpecialFileNameVH{VHHgetVHH{KVHHH// AVHHHKreturn string.Format(X{0}{1}text-{2:yyyy-MM-dd_hh-mm-ss-tt}.binX,KVHHHH// BVHHHHKEnvironment.GetFolderPath(Environment.SpecialFolder.MyDocuments),KVHHHH// CVHHHHKPath.DirectorySeparatorChar,KVHHHH// DVHHHHKDateTime.Now);VHH}VH}VVHstatic void Main()VH{VHHConsole.WriteLine(SpecialFileName);VH}V}VVKVVC:\\Users\\Sam\\Documents\\text-2008-11-18_05-23-13-PM.binK","A*BEDrAB.CP1B| 64F(B 6666}(CCE(XCE/C","Filename, DateTime."," A filename can store the date and time. This clearly identifies the file in a unique way. There are many ways of accomplishing this. Some are clearer to read and easier to modify than others. We include the date, or the date and the time. ","You can use DateTime formatting for filenames. A format string is provided.","Example."," We use the current date and time as the name for a file on the file system. We call the string.Format method, and combine it with DateTime.Now, for a method that outputs the correct string based on the date and time. ","DateTime.Now ","datetime-now","Environment.SpecialFolder."," You can use this code with Environment.SpecialFolder. You can encapsulate the logic for this in a property accessor. In other words, you can use a property to easily get the complete filename. ","Property ","property","This example"," uses a format string in part A. This format string has three placeholders: first, the directory name we get from SpecialFolder, then the separator char, and finally the specially formatted DateTime. ","The code specifies that the file name starts with text and ends with \".bin\".","Next: ","It gets the My Documents folder path. This line uses the SpecialFolder.MyDocuments enum value to get the path.","Environment ","environment","Finally,"," it uses Path.DirectorySeparatorChar. On Windows, this is the backslash. You could just use \\\\ in the string instead. It uses DateTime.Now. As expected, this returns the local time.","Separators."," You can change the string separators by replacing the underscores and dashes with any other character, excluding some special ones. I haven't found many uses for separators other than dashes, underscores, and spaces. ","Filenames cannot have some characters. This is explored further in a separate article.","Reserved Filenames ","reserved-filenames","Summary."," We generated file names containing the current date. This is useful for \"data dumps\" and log files where daily files are written. Never use random names except when you need temporary files. It is often better to append the date. ","If you have to write files frequently, using the \"ss\" field can help\u2014this writes seconds."]

%iVBORw0KG;)NSUhEUg?AL4?ABBCAM?ABYbu5j)MFBMVEX:/+1wv+jqv9siv/p6:W3f8zZv9gb:19v9NK/8zAP999:S:8z:8zzP+z6P/0gInF?ABg0lEQVR4XtXXy1ICURAD0H7c96D+/9/KQqkhlEKD0iTrWZzKYtJXbou2s+jvn1Q55f2mfAMOb6Ec5D6+c/ObcvOdm98qN9+5+a1w842b3wo33/6Dv2H22g3zCL+PKF/uSKDsGL8pN9+5+U25+c7Nb5Wb74R8h+ki41eYLja+Qf1k/AL1k/HF4XIg4ytMFxl/X7/z8aF+Ov6A6bqR:FTnswXa2B96LmyPZtfoH4yvsDlwMaHy4GLj/Xz8RXqJ+PD5UDGh+ni448O08XEh+lSrtUVnC6qm+ey/krGx+li4+N0sfHh7Cfj43Sx8bF+Mj5OFxkf67c8frF+jJUovzRIBr/4+kovMb5YPr/OdcrUGL9k8FG/Tw3xxbP55/o1R4hfk/m6IBbii+fyJ/JnjK+5/HWRGuJLfzG+xvh6lX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