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);

     

  • 相关阅读:
    js 获取时间差
    linq 两个list合并处理,并分组
    单例模式 双锁
    2018年的读书清单
    感悟
    asp.net使用Microsoft.mshtml提取网页标题等解析网页
    //利用反射快速给Model实体赋值
    C# url接口调用
    多字段动态查询
    对图片的操作
  • 原文地址:https://www.cnblogs.com/Gemgin/p/3136227.html
Copyright © 2011-2022 走看看