Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

Cheeso

@Cheeso
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem: .NET 2.0 File.GetLastWriteTime(path) Keeps adding 1 hour
    C Cheeso

    No, the problem occurs because Win32 and .NET make different choices with regard to dealing with Daylight Saving Time. For a discussion, see here: http://blogs.msdn.com/oldnewthing/archive/2003/10/24/55413.aspx To compensate, you have to adjust the time you use with SetLastWriteTime and GetLastWriteTime. When setting, adjust from .Net to Win32. When getting, adjust from Win32 to .NET. Here's some example code:

    // If I have a time in the .NET environment, and I want to use it for
    // SetWastWriteTime() etc, then I need to adjust it for Win32.
    static DateTime AdjustTime_DotNetToWin32(DateTime time)
    {
    DateTime adjusted = time;
    if (DateTime.Now.IsDaylightSavingTime() && !time.IsDaylightSavingTime())
    adjusted = time - new System.TimeSpan(1, 0, 0);
    else if (!DateTime.Now.IsDaylightSavingTime() && time.IsDaylightSavingTime())
    adjusted = time + new System.TimeSpan(1, 0, 0);

    return adjusted;
    }

    // If I read a time from a file with GetLastWriteTime() (etc), I need
    // to adjust it for display in the .NET environment.
    static DateTime AdjustTime_Win32ToDotNet(DateTime time)
    {
    DateTime adjusted = time;
    if (DateTime.Now.IsDaylightSavingTime() && !time.IsDaylightSavingTime())
    adjusted = time + new System.TimeSpan(1, 0, 0);

    else if (!DateTime.Now.IsDaylightSavingTime() && time.IsDaylightSavingTime())
    adjusted = time - new System.TimeSpan(1, 0, 0);
    
    return adjusted;
    

    }

    void MySetLastWriteTime(String targetFile, DateTime t)
    {
    DateTime adjusted = AdjustTime_DotNetToWin32(t);
    System.IO.File.SetLastWriteTime(targetFile, adjusted);
    }

    DateTime MyGetLastWriteTime(String targetFile)
    {
    DateTime t = System.IO.File.GetLastWriteTime(targetFile);
    return AdjustTime_Win32ToDotNet(t);
    }

    Visual Basic question csharp help

  • Zip Compression in C#
    C Cheeso

    Works great, very speedy, good compression, good features. Recommended!

    C# csharp question

  • Accessing a Text File in Password Protected Zipped Folder
    C Cheeso

    As of February 2009, DotNetZip works with ZIP files above 4g in size. Get v1.7 or later.

    Visual Basic csharp database help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups