c# - Will this DateTime optimization cause localization problems? Will it be more efficient? Is it worth it? -


I am working on updating the project that is based on the date to keep the file in a folder in the following code Uses:

  int month = date template.Number; String zero = (month & lt; 10)? "-0": "-"; String folder = "folder" + date time.Now year. Toasting () + zero + months Toaster () + "\\"; If (! Directory.Exists (folder)) {Directory.CreateDirectory (folder); } ArchiveFolder = Folder; // ... date time now = date time.Now; Int date = now.Day; String zero = (date & lt; 10)? "0": ""; String saveaspath = zero + date Toasting () + "_" + now For time (+) + "_" + name; #if DOTNET20 foreach (path in c.ChatInvalidFileNameChars ()) #ELse foreach (Four C. in Path Charges Invalid Path) #endif saveaspath = saveaspath.Replace (c, '-'); // Option - saveaspath = saveaspath.Replace (':', '-') for bad characters; String originalname = escapepath; String ext = ".ext"; Saveaspath = Path. Cobain (archivefalzer, servapath + ext.); Int count = 1; While (file.existits) // Make unique {string num = "(" + count ++. ToString () + ")"; Saveaspath = Path. Cobain (archive folder, original name + + + + x + ext); }  

Example generated file: folder / 2010-06 / 18_2-42-09 PM_name.x

Due to the nature of the program at one time, usually to create multiple files.

I was thinking of updating the date time relevant to the datetime format strings - I thought maybe all these different toasting () should be more efficient than the calls; Although I'm worried that when a user has different culture settings then, this current code can be some funky - I do not know.

So: Should I redo the code using the format strings? Or is it in the form of leave? Will this benefit the performance? Will this culture depend?

(To clarify: My question is not to reproduce this format using the string, rather, I am worried about the effect of doing this.)

Should I redo the code using the format string?

This one

Or leave it and leave it?

If the current behavior is not broken, then there is a lot more robust and maintained, it is important for you to leave it, it may be best to leave it on the other side, if it has been found that existing If there is a bug in the code then it may be a good oppurtunity to rewrite it with scratch.

Will this display profit?

If your code is writing the files, I hardly think that the time spent creating the string will be interrupted. There is a very slow operation compared to being written in a file.

Will it be culture-dependent?

Use during formatting to avoid culture dependence.


Comments