DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

Candle

  • Participant
  • Joined in 2006
  • *
  • Posts: 18
IDEA: monitor folder for max MB and get message
« on: January 20, 2007, 10: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, 10:18 AM by brotherS »

CodeTRUCKER

  • Bush Flying... where I'd rather be.
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,086
    • Participated in NANY Challenge Once
    • Military Service Badge - US Navy
Re: IDEA: monitor folder for max MB and get message
« Reply #1 on: January 20, 2007, 10: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.
DISCLAIMER - I have made and make many threads for questions and even project posts across the Internet. Unfortunately, many are in limbo because I cannot remember where they are at. If anyone knows of an open thread or an unanswered inquiry, please PM me. Thank you.
   
Notice: Unless stated otherwise, I receive no compensation for anything I post here.
« Last Edit: December 08, 2009, 11:28 PM by CodeTRUCKER »

Candle

  • Participant
  • Joined in 2006
  • *
  • Posts: 18
Re: IDEA: monitor folder for max MB and get message
« Reply #2 on: January 20, 2007, 10:58 AM »
Thanks for the help.

CodeTRUCKER

  • Bush Flying... where I'd rather be.
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,086
    • Participated in NANY Challenge Once
    • Military Service Badge - US Navy
Re: IDEA: monitor folder for max MB and get message
« Reply #3 on: January 20, 2007, 02:53 PM »
Anytime.  :)
DISCLAIMER - I have made and make many threads for questions and even project posts across the Internet. Unfortunately, many are in limbo because I cannot remember where they are at. If anyone knows of an open thread or an unanswered inquiry, please PM me. Thank you.
   
Notice: Unless stated otherwise, I receive no compensation for anything I post here.
« Last Edit: December 08, 2009, 11:26 PM by CodeTRUCKER »

chedabob

  • C# Master (if only!!!)
  • Participant
  • Joined in 2006
  • *
  • Posts: 34
Re: IDEA: monitor folder for max MB and get message
« Reply #4 on: January 20, 2007, 06: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).

Code
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, 08:06 PM by chedabob »

Candle

  • Participant
  • Joined in 2006
  • *
  • Posts: 18
Re: IDEA: monitor folder for max MB and get message
« Reply #5 on: January 20, 2007, 09: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

  • C# Master (if only!!!)
  • Participant
  • Joined in 2006
  • *
  • Posts: 34
Re: IDEA: monitor folder for max MB and get message
« Reply #6 on: January 20, 2007, 10: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
  • *
  • Posts: 18
Re: IDEA: monitor folder for max MB and get message
« Reply #7 on: January 20, 2007, 10: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

  • Bush Flying... where I'd rather be.
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,086
    • Participated in NANY Challenge Once
    • Military Service Badge - US Navy
Re: IDEA: monitor folder for max MB and get message
« Reply #8 on: January 20, 2007, 10:39 PM »
I'm looking forward to this too!
DISCLAIMER - I have made and make many threads for questions and even project posts across the Internet. Unfortunately, many are in limbo because I cannot remember where they are at. If anyone knows of an open thread or an unanswered inquiry, please PM me. Thank you.
   
Notice: Unless stated otherwise, I receive no compensation for anything I post here.
« Last Edit: December 08, 2009, 11:30 PM by CodeTRUCKER »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • Participated in NANY Challenge Twice
    • Coding Snacks
Re: IDEA: monitor folder for max MB and get message
« Reply #9 on: January 21, 2007, 03:38 AM »
:) This should do it.

To compile it, download AutoHotkey.

Skrommel


Code
;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
  • *
  • Posts: 18
Re: IDEA: monitor folder for max MB and get message
« Reply #10 on: January 21, 2007, 03:45 AM »
Thanks you, I'll add a
Code
FileSelectFolder, OutputVar [, StartingFolder, Options, Prompt] 
to it .

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • Participated in NANY Challenge Twice
    • Coding Snacks
Re: IDEA: monitor folder for max MB and get message
« Reply #11 on: January 21, 2007, 01:09 PM »
:) As usual the simple solution is the best, Candle!

Skrommel

Original address: https://www.donationcoder.com/forum/index.php?topic=7086.0