nV News Forums


nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   Need to make a super simple program (http://www.nvnews.net/vbulletin/showthread.php?t=115194)

Infinity666 06-21-08 10:14 PM

Need to make a super simple program
All I need the ability to copy a few files from one directory to another but it needs to do this every 2 seconds or so.... im a complete programing novice but i have access to visual basic.


jcrox 06-22-08 05:48 PM

Re: Need to make a super simple program
You need to be a little more specific

Where is the source of the file?
Where is the destination of the file?
What kind of file is it?
Are you looking to "read" the file and write its contents to a different file or do you want to copy the object itself(which brings more questions)?

edit: oh yeah, visual studio supports quite a few options for languages... you looking for something in java, c#, .NET...???

wnd 06-23-08 07:41 AM

Re: Need to make a super simple program

#! /bin/sh

while true; do
        cp -dpR source destination
        sleep 2

Especially if you only need to do this temporarily, a simple script should suffice just fine. Note that if you're processing large number of files, two second interval could prove to be a bit too short.

If you want to make copying smarter (only copy the files when they're changed), use rsync.


#! /bin/sh

while true; do
        rsync -u source destination
        sleep 2

If you want copying to /start/ every N seconds, you could replace the main loop with something like the following. It will /not/ handle fractions of seconds well so it's not very accurate.


n=10 # start copy every N seconds
before=$(date +%s)
while true; do
        # copying happens here
        after=$(date +%s)
        sleep $(( n - after + before ))
        before=after # save one call to date

If you're running Windows you can install Cygwin, or rewrite the script as batch-program.

ViN86 06-26-08 04:09 PM

Re: Need to make a super simple program
i would do it with C# and i would make a GUI that allows you to specify the source directory and the target directory for the copy. also, do you want to rename the files each time?

dxx 06-26-08 05:05 PM

Re: Need to make a super simple program
For maximum ease, I'd just cheat. Make a super-super-simple VB app that has only two functions, a timer, and a bit of code to execute an external batch file. Here's how to do it:

1) Create a new VB project
2) Drag the timer icon onto the main program window
3) Double-click the timer
4) Paste the code below under the timer function -

Private Sub Form_Load()
Shell ("c:\copything.bat")
End Sub

(I think that should work, it's been about a year since I last wrote a VB app that called upon other exe's)
5) Add a button to the page, name it "Start"
6) Double-click it, enter


7) Compile, it should work.

All times are GMT -5. The time now is 03:15 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.