源码如下:using System.Management;using System.IO;
在你的事件中添加如下代码
ConnectionOptions conn = new ConnectionOptions(); conn.Username = "Administrator";//登入远端电脑的账户 conn.Password = "hanroc";//登入远端电脑的密码 ManagementPath path = new ManagementPath();
//其中root\cimv2是固定写法 path.Path = @"\\172.26.41.1\root\cimv2"; ManagementScope ms = new ManagementScope(); ms.Options = conn; ms.Path = path; ms.Connect(); //这里的例子读取文件的最后修改日期 ObjectQuery query = new ObjectQuery("SELECT * FROM CIM_DataFile WHERE Name = 'C:\\\\KVOffice.log'"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms,query); ManagementObjectCollection collection = searcher.Get(); string time = ""; foreach (ManagementObject obj in collection) { time = obj.Properties["LastModified"].Value.ToString().Substring(0,14); }
Response.Write(time);
转载于:https://www.cnblogs.com/tuyile006/archive/2006/11/10/556459.html
