zoukankan      html  css  js  c++  java
  • 编程经验:修改文件属性时间

    //C语言修改文件时间

     

    #include <stdio.h>

    #include <process.h>

    #include <fcntl.h>

    #include <io.h>

     

    FILE *fp;

    fp = fopen(strBinPath, "w");

     

    struct ftime filet;

    filet.ft_year = 2004;

    filet.ft_month = 8;

    filet.ft_day = 17;

    filet.ft_hour = 20;

    filet.ft_min = 0;

    filet.ft_tsec = 1;

     

    setftime(fileno(fp), &filet);

     

    ------------------------------------------------------------------------------------------------

     

    //C++ 修改文件时间

     

    #include <windows.h>

    #include <stdlib.h>

     

    HANDLE hFile;

    hFile = CreateFile (strBinPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);

     

         SYSTEMTIME st;

         memset(&st, 0, sizeof(st));

         st.wYear = 2004;

         st.wMonth = 8;

         st.wDay = 17;

         st.wHour = 20;

         st.wMinute = 0;

         FILETIME ft,LocalFileTime;

         SystemTimeToFileTime(&st, &ft);

         LocalFileTimeToFileTime(&ft,&LocalFileTime);

     

         SetFileTime(hFile, &LocalFileTime, (LPFILETIME) NULL,   &LocalFileTime);

     

  • 相关阅读:
    分布式事务
    K8s应用案例介绍——阿里云
    数据库索引的底层原理——b树
    Understanding the GitHub flow
    Code Review
    详解微服务架构
    yarn之package.json
    yarn.lock文件
    Git Api——git开发
    Unit Test —— xUnit.net
  • 原文地址:https://www.cnblogs.com/Gemgin/p/3136227.html
Copyright © 2011-2022 走看看