본문 바로가기

분류 전체보기171

c# memory cache private void btnGet_Click(object sender, EventArgs e) { ObjectCache cache = MemoryCache.Default; string fileContents = cache["filecontents"] as string; if (fileContents == null) { CacheItemPolicy policy = new CacheItemPolicy(); List filePaths = new List(); filePaths.Add("c:\\cache\\example.txt"); policy.ChangeMonitors.Add(new HostFileChangeMonitor(filePaths)); // Fetch the file contents. fileCon.. 2018. 5. 26.
Deleting multiple files with wildcard var dir = new DirectoryInfo(directoryPath); foreach (var file in dir.EnumerateFiles("f*.txt")) { file.Delete(); }SOURCE : https://stackoverflow.com/questions/8807209/deleting-multiple-files-with-wildcard?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa 2018. 5. 17.
How to crop an image using C#? static Bitmap LoadImage() { return (Bitmap)Bitmap.FromFile( @"e:\Tests\d_bigImage.bmp" ); // here is large image 9222x9222 pixels and 95.96 dpi resolutions } static void TestBigImagePartDrawing() { using( var absentRectangleImage = LoadImage() ) { using( var currentTile = new Bitmap( 256, 256 ) ) { currentTile.SetResolution(absentRectangleImage.HorizontalResolution, absentRectangleImage.Vertical.. 2018. 5. 9.
Get utc time to time zone standard time public static DateTime GetKoreaStdTime() { DateTime localTime = DateTime.Now; try { //DateTime serverTime = DateTime.Now; // gives you current Time in server timeZone //ateTime utcTime = serverTime.ToUniversalTime(); // convert it to Utc using timezone setting of server computer DateTime utcTime = DateTime.UtcNow; TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Korea Standard Time"); loc.. 2018. 4. 9.