C#使用file无法修改netware操作系统下的文件创建日期

因某些原因需要更改Netware网络操作系统下的文件创建时间,但只能更改最近修改时间,文件创建时间修改不成功。

相同代码在更改Windows服务器的文件时可以更改成功。

代码如下:

        public  void RefreshFilterFilesDate(string strFilter, string strPath, int iYear, int iMonth, int iDay, int iHour, int iMinute)
{

int deYear, deMonth, deDay, deHour, deMinute;
bool isExist = System.IO.Directory.Exists(strPath);
if (isExist)
{
deYear = iYear;
deMinute = iMonth;
deDay = iDay;
deHour = iHour;
deMinute = iMinute;
string[] myTxtFiles = Directory.GetFiles(strPath, strFilter, SearchOption.AllDirectories);
foreach (string myTxtFile in myTxtFiles)
{
DateTime dateModified;
DateTime oldDate, newDate;
myNCFile = myTxtFile;
oldDate = File.GetCreationTime(myTxtFile);
dateModified =File.GetLastWriteTime(myTxtFile);

if (oldDate.CompareTo(dateModified) < 0)
{
oldDate = dateModified;
}

deYear = iYear == 0 ? 2002 : iYear;
deMonth = iMonth == 0 ? oldDate.Month : iMonth;
deDay = iDay == 0 ? oldDate.Day : iDay;\\问题出在这里,月份为2,日期〉28时出错
deHour = iHour == 0 ? oldDate.Hour : iHour;
deMinute = iMinute == 0 ? oldDate.Minute : iMinute;
newDate = new DateTime(deYear, deMonth, deDay, deHour, deMinute, oldDate.Second,oldDate.Millisecond);
TimeSpan ts = newDate.Subtract(oldDate);

if (newDate != oldDate)
{
File.SetCreationTime(myTxtFile, newDate);
File.SetLastWriteTime(myTxtFile, newDate);

myNCFile = myNCFile + "\t" + oldDate + "\t" + newDate;
InvokeDoWith mi = new InvokeDoWith(AddLVItem);
this.Invoke(mi);
}
}
}
}

 

您有什么方法实现吗?

转载于:https://www.cnblogs.com/HFTech/archive/2012/01/10/2318095.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值