Checking FileSize and Redirecting Large Files
Hello,
I am working on a new development tool that would impact Logon/Logoff times,
as well as increase network bandwidth usage.
Goal of the project is, for Windows 7, to create a tool that at logon checks the sizes of the files on the desktop and if the file reaches certain size, takes some action: whether warns the user to do something with these files or copies the files to a share Drive and creates desktop shortcuts.
Was looking to do this with a form using C#. Before I begin was wondering if there were any examples out there of anything similiar to look at or any sample code of how to collect the filesizes and then move the larger files.
Thank You for your help!
Re: Checking FileSize and Redirecting Large Files
I don't know how deep is your c# or .net knowledge but this might help you:
FileInfo.Length Property
Re: Checking FileSize and Redirecting Large Files
Thank You for the Reply.
This will help me get off to a great start.
Re: Checking FileSize and Redirecting Large Files
Hello,
I have used the fileinfo.length method successfully.
I have scanned my directory, displayed all filenames and file lengths.
I now have one last task to Redirect any files that are > then a fixes length and Move them to a new folder on a Share Drive.
I have all the logic in place that checks the filesize and tried using the fileinfo.MoveTo() Method.
However found this to take my current files and move them to a directory but also rename them.
Looking to just Move the file from its current directory into a new directory if it exceeds a size.
Which method would work best for this?
Thank You.
Re: Checking FileSize and Redirecting Large Files
that's the way how the move method works. just use the same name so it does not get renamed.
Re: Checking FileSize and Redirecting Large Files
Yeah only problem is I have an array where it is locating multiple files from Directory A and if they exceed a certain size it is moving them to Directory B though.
Think I got it though.
DirectoryInfo di = new DirectoryInfo("C:\\OldFolder");
FileInfo[] fiArr = di.GetFiles();
foreach (FileInfo f in fiArr)
{
if (f.length > 10000 )
{
f.MoveTo(@"C:\NewFolder" + f.Name);
}
else....
}
Thinking this should do the trick.