Monday 31 August 2009

Using Robocopy to delete old files from folder

There are numerous occasions where you may want to keep a folder tidy and remove older files.

We needed a solution for a shared folder that we wanted to control so that users didn't use it as a lazy dumping ground for their files.

After a bit of searching I found a novel way of using robocopy to accomplish exactly what we wanted.
mkdir c:\delete
c:\robocopy.exe c:\Source c:\Delete /e /MOVE /MINAGE:14 /LOG+:c:\robocopy.log
rmdir c:\delete /s /q

This script creates a folder called 'delete'. Then uses robocopy to move files older than 14 days from the 'source' folder to the 'delete' folder. Lastly it deletes the 'delete' folder so that only files newer than 14 days is left in the 'source' folder.

Notes:
Remember to change the location of the robocopy executable, robocopy.log, your source and delete folders.
Add '/XF [filename]' to the robocopy line in order to exclude one or more files from being deleted (if required).

Original article can be found here. (Pure genius!)

Monday 17 August 2009

Fix - Interference on Image for Sky Digital Channels

SKY at nightFor the past few months we have been having problems with scrambled picture on some Sky Digital Channels. The interference on the image was similar to how the picture scrambles in bad weather.

The problem only affected certain channels including True Movies (321) True Movies + 1 (322) and Brit Asia (833). All the affected channels were free to air and it only affected them some of the time. If you ever went onto an affected channel and then changed to a different channel, then the Sky Digital box would crash. The only way to fix the problem was to reset the box at the mains. We even tried a new box but the problem persisted.

Finally we found our landline phone was affecting the picture. Our landline phone is a digital phone and some how it was affecting the picture sometimes.

We have now moved the phone away from the Sky box and the problem has been fixed.

Hope this helps someone.

Thursday 6 August 2009

System.IO.FileloadException error

At work we had an issue when trying to deploy a .Net 3.5 application to servers.

It would work correctly on all our development machines but when we deployed it to the server the process would show up in Task Manager but then disappear.

We found an entry in the Event Viewer as shown below

----------------------------------------------------------------------------------

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 06/08/2009
Time: 11:29:34
User: N/A
Computer: XXX
Description:
EventType clr20r3, P1 xxx.exe, P2 1.0.0.0, P3 4a7aaf1b, P4 xxx, P5 1.0.0.0, P6 4a7aaf1b, P7 9a, P8 f, P9 system.io.filenotfoundexception, P10 NIL.

-------------------------------------------------------------------------------------

We found that a system.io.filenotfoundexception means that the application cannot find a dll / assembly of some sort, but we didn't know the name of the dll or assembly. After a bit of digging (http://stackoverflow.com/questions/295161/) we found that we could catch exceptions when the main form is loaded in (Program.cs) as below:

try
{
Application.Run(new MainForm());
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);

}


When we ran the application on the server we got an error
The error showed that the ReportingServices dlls were the wrong version. We had copied 2005 (version 8.0.0.0) dlls into the application folder, but our application required 2008 (version 9.0.0.0) dlls.

Hope this helps some one