Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [VB.NET] Copy files in a folder depending on file size
New Posts  All Forums:Forum Nav:

[VB.NET] Copy files in a folder depending on file size

post #1 of 7
Thread Starter 
Hi OCN members smile.gif

I'm trying to make a little app that will scan our shared drive (X:) and copy all the AVI and MP4 files that are over 100MB to a folder on my C drive.
The point of this is to convert them into a smaller size to save space and it gets tiring scanning that drive everyday for files and copying them back and fourth.
Any ideas on how to do it? I've tried using the FileInfo.Length and FileCopy but that only works with one file and cannot find a way to make it work with multiple files.

If you need any more information then just ask smile.gif
post #2 of 7
Quote:
Originally Posted by fleXx View Post

tried using the FileInfo.Length and FileCopy but that only works with one file and cannot find a way to make it work with multiple files.

You just need to recursively / loop around the directory.

http://support.microsoft.com/kb/303974
from site.
Code:
void DirSearch(string sDir) 
{
        try     
        {
           foreach (string d in Directory.GetDirectories(sDir)) 
           {
                foreach (string f in Directory.GetFiles(d, txtFile.Text)) 
                {
                   lstFilesFound.Items.Add(f);[B]  // you can then search this list for the files with a for loop.[/B]
                }
                DirSearch(d);
           }
        }
        catch (System.Exception excpt) 
        {
                Console.WriteLine(excpt.Message);
        }
}
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
post #3 of 7
Thread Starter 
Isn't that code in C though? I need a VB version tongue.gif thanks
post #4 of 7
Quote:
Originally Posted by fleXx View Post

Isn't that code in C though? I need a VB version tongue.gif thanks

Its c#. But I was more posting that as a consept/general design.

I have no interest in VB or C# to be honest, both are useless, don't see the point in C#, for running in vm java is fine plus is xplatform. And VB erh. why?
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
post #5 of 7
Thread Starter 
Because im just starting out and I need a basic language, I've looked at python but it looks like it doesn't really work out for application programming
post #6 of 7
Quote:
Originally Posted by fleXx View Post

Because im just starting out and I need a basic language, I've looked at python but it looks like it doesn't really work out for application programming

Learn java then (look at c/c++ after). vb is a waste of time.
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
^3
(11 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i7 5930K  EVGA x99 Micro EVGA GTX 980 SC ACX 16GB Corsair DDR4 Vengeance LPX Black PC4-21300 
Hard DriveCoolingOSMonitor
500GB Samsung 840 EVO H105 Win 10 ASUS ROG PG279 
KeyboardPowerCase
Ducky Shine 1 MX-Red Corsair AX 860i  Fractal Design Node 804 Black 
CPUGraphicsRAMHard Drive
Core i7 @ 2.6  GT650 16GB of 1600 MHz DDR3L SDRAM 256GB SSD 
OSMonitorKeyboard
Mac OSX Lion Retina Display US layout 
  hide details  
Reply
post #7 of 7
VB.NET is fine to learn application programming.

There's a lot of snobbishness regarding Visual Basic (and given the early versions, you'd be right). But these days it's a pretty powerful language.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [VB.NET] Copy files in a folder depending on file size