topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 10:47 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: monitor folder for max MB and get message  (Read 9383 times)

Candle

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 18
    • View Profile
    • Donate to Member
IDEA: monitor folder for max MB and get message
« on: January 20, 2007, 04:01 AM »
I was working on this but not having a lot of luck so will ask if someone gets sometime to maybe do this.
I download a lot of files to one folder and want to burn the folder to dvd disk when it hits about 4 gigs ,so need something to watch it for me and when it hits that size it gives me a message .
« Last Edit: January 20, 2007, 04:18 AM by brotherS »

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #1 on: January 20, 2007, 04:29 AM »
That sounds real handy!  FYI - sometimes it takes a little while, but you will get help and this will be done.  A bunch of real smart and helpful folks hang out at DC.
« Last Edit: December 08, 2009, 05:28 PM by CodeTRUCKER »

Candle

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 18
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #2 on: January 20, 2007, 04:58 AM »
Thanks for the help.

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #3 on: January 20, 2007, 08:53 AM »
Anytime.  :)
« Last Edit: December 08, 2009, 05:26 PM by CodeTRUCKER »

chedabob

  • Participant
  • Joined in 2006
  • *
  • Posts: 34
  • C# Master (if only!!!)
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #4 on: January 20, 2007, 12:31 PM »
I could try this, don't think it would be too hard. Gimme half an hour, and Ill have a look

EDIT: Actually, might take a little longer than expected, I gotta get my head around this silly size method.

EDIT2: So, this is my code so far. Its not tidy or anything, but it works slightly. Could somebody explain why it gives me some stupid value? Like for My Pictures, it gives 1180, when in fact, the closest value it could be is 876kb (the actual value according to windows explorer).

private void button1_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text.ToString();
            string [] directorylist = null;
            string [] filelist = null;
            directorylist = Directory.GetDirectories(input);
            int counterD = 0;
            int counterF = 0;
            double size = 0;
            if (Directory.Exists(input) == true)
            {
               do
               {
                   filelist = Directory.GetFiles(directorylist[counterD]);
                    do
                    {
                        size = size + filelist[counterF].Length;
                        counterF++;
                    }
                    while (counterF <= filelist.Length - 1);
                    counterF = 0;
                   counterD++;
               } while (counterD <= directorylist.Length - 1);
               MessageBox.Show(size.ToString());
            }
            else
            {
                MessageBox.Show("No such Directory. Check path and try again!");
            }
           
        }
« Last Edit: January 20, 2007, 02:06 PM by chedabob »

Candle

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 18
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #5 on: January 20, 2007, 03:49 PM »
Thank you for the help. I guess if it gives the gen size of the folder that would be close.
Most of the files would be zip or rar files .

chedabob

  • Participant
  • Joined in 2006
  • *
  • Posts: 34
  • C# Master (if only!!!)
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #6 on: January 20, 2007, 04:06 PM »
What Im trying to do is find out where that value is coming from. If its just a simple matter of me expecting it in KB that are 1024 bytes, and its reading them out as 1000bytes in a KB, then Ill just modify the output. Ill do a bit mroe tommorrow.

Do you have any folders within your download folder? Or just files?

Candle

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 18
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #7 on: January 20, 2007, 04:16 PM »
Yes I guess they maybe a few of what I have open and look at but would just care about the zip, rar and exe files that are there.
Thanks for the help with this.

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #8 on: January 20, 2007, 04:39 PM »
I'm looking forward to this too!
« Last Edit: December 08, 2009, 05:30 PM by CodeTRUCKER »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #9 on: January 20, 2007, 09:38 PM »
 :) This should do it.

To compile it, download AutoHotkey.

Skrommel


;FolderLimit.ahk
;  Shows a message when a folder is bigger than a limit
;Skrommel @2007

folder=C:\Test   ;Folder to count and recurse
limit=4000       ;MBs to watch for
pause=10         ;Seconds to wait beween checks
exit=1           ;1=Exit when limit reached  0=Don't

#NoEnv
#Persistent

1mb:=1024*1024   ;Size of 1MB in Bytes
limit:=limit*1mb

Loop
{
  size=0
  Loop,%folder%\*.*,1,1
    size+=%A_LoopFileSize%
  If size>=%limit%
  {
    MsgBox,% folder . " = " . Floor(size/1mb) . "MB > " . Floor(limit/1mb) . " MB!"
    If exit=1
      ExitApp
  }
  Sleep,% pause*1000
}

Candle

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 18
    • View Profile
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #10 on: January 20, 2007, 09:45 PM »
Thanks you, I'll add a
FileSelectFolder, OutputVar [, StartingFolder, Options, Prompt]
to it .

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: monitor folder for max MB and get message
« Reply #11 on: January 21, 2007, 07:09 AM »
 :) As usual the simple solution is the best, Candle!

Skrommel