用FileInfo得到的文件时间怎么不对呢?

anjoe1979 2011-11-02 02:51:03
FileInfo fi = new FileInfo("//1.exe")
...全文
144 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
91program 2011-11-03
  • 打赏
  • 举报
回复
不对,究竟是怎么个不对法?

提问,最好能说清楚,不要让别人猜!
cherry9400 2011-11-03
  • 打赏
  • 举报
回复
问题好像不清楚。能描述详细些吗?
那个“//1.exe” 应该是“\\1.exe”个吧?
检查一下你的Device上系统时间的设置是否是现在的time zone和现在的时间。然后再判断时间是不是正确。
woshi_ziyu 2011-11-03
  • 打赏
  • 举报
回复
很显然是你的文件路径设置的不正确
FileInfo类

官方提供的代码


//下面的示例演示了 FileInfo 类的一些主要成员。
using namespace System;
using namespace System::IO;

int main()
{
String^ path = Path::GetTempFileName();
FileInfo^ fi1 = gcnew FileInfo( path );
if ( !fi1->Exists )
{
//Create a file to write to.
StreamWriter^ sw = fi1->CreateText();
try
{
sw->WriteLine( "Hello" );
sw->WriteLine( "And" );
sw->WriteLine( "Welcome" );
}
finally
{
if ( sw )
delete (IDisposable^)sw;
}
}

//Open the file to read from.
StreamReader^ sr = fi1->OpenText();
try
{
String^ s = "";
while ( s = sr->ReadLine() )
{
Console::WriteLine( s );
}
}
finally
{
if ( sr )
delete (IDisposable^)sr;
}

try
{
String^ path2 = Path::GetTempFileName();
FileInfo^ fi2 = gcnew FileInfo( path2 );

//Ensure that the target does not exist.
fi2->Delete();

//Copy the file.
fi1->CopyTo( path2 );
Console::WriteLine( "{0} was copied to {1}.", path, path2 );

//Delete the newly created file.
fi2->Delete();
Console::WriteLine( "{0} was successfully deleted.", path2 );
}
catch ( Exception^ e )
{
Console::WriteLine( "The process failed: {0}", e );
}
}

19,520

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧