Reputation: 1
I am fairly new to C# and was hoping for some assistance. I currently use Visual Studio 2008. What I am wanting to do is the following:
I have a server (\backupserv) that runs a RoboCopy script nightly to backup directories from 18 other servers. These directories are then copied down to \backup in directories of their own:
Example: It copies down "Dir1", "Dir2", and "Dir3" from Server1 into \backupserv\backups\Server1 into their own directories (\backupserv\backups\Server1\Dir1, \backupserv\backups\Server1\Dir2, and \backupserv\backups\Server1\Dir3).
It does this for all 18 servers nightly between 12am and 6am. The RoboCopy runs via schedule task. A log file is created in \backupserv\backups\log and is named server1-dir1.log, server1-dir2.log, etc.
What I am wanting to accomplish in C# is the ability to have a 'report' showing the modified date of each text log file. To do this I need to browse the \backupserv\backups\log directory, determine the modified date, and have a report displayed (prefer HTML if possible). Along with the modified date I will be showing more information, but that is later.
Again, I am fairly new to C#, so, please be gentle. I was referred here by another programmer, and was told I would get some assistance.
If I have missed any detail please let me know and I will do my best to answer.
Upvotes: 0
Views: 1093
Reputation: 55966
The System.IO.FileInfo
class should still work on a UNC Path (i.e. \\Myserver\some\folder
) provided the user running the application has appropriate permissions to access that directory.
public DateTime? GetModifiedTime(string fileName)
{
DateTime? retVal = null;
try
{
FileInfo fi = new FileInfo(fileName);
retVal = fi.LastWriteTime; // .LastWriteTimeUtc if you want it in UTC
}
catch(IOException ioe)
{
// Do something with the IO Exception, could be a permissions thing,
// could be file not found, you should split it into a couple
// different catch() {} blocks to handle them seperately.
}
return retVal;
}
Upvotes: 2
Reputation: 8258
You can start with a console application.
Upvotes: 2