Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Simple Batch Type Program

Reply
 
Old 04-10-2008   #1 (permalink)
Paul W Smith


 
 

Simple Batch Type Program

I would like to have a simple application that copies a file from one folder
to another, changing the name of the file and overwriting the file in the
destination location.

Copy: C:\abc\def\ghi\jklmnopqrt.txt (long file name)

to

C:\zyx\wvu\tsrq\ ..... overwriting file xxxx.text

I have been able to do this using a simple DOS batch file but this does not
work with long file names.

In windows terms I would like a short-cut on my desktop to an application
which does this procedure on demand.

Using a batch file was so simple is it complicated because of the use of
lonf file names?

Any advise or code greatfully received.

Paul Smith



My System SpecsSystem Spec
Old 04-10-2008   #2 (permalink)
Miro


 
 

Re: Simple Batch Type Program

This might get you started -
http://www.homeandlearn.co.uk/NET/nets8p6.html

Just check if the file exists, and you can delete it first, or rename it...
Not sure if you want to keep an ongoing archive of the same file or replace
it all together?

Do you want to just copy these files once a week or something? or when the
file name changes?
Take a look at the 'filewatcher' - cant remember the control off hand and i
dont have vs open, but you can let an event occur
when the file actaully changes...so teh copy would happen for you
automatically if someone changes the file on you.

M.

"Paul W Smith" <pws@xxxxxx> wrote in message
news:OzUjVwymIHA.5660@xxxxxx
Quote:

>I would like to have a simple application that copies a file from one
>folder to another, changing the name of the file and overwriting the file
>in the destination location.
>
> Copy: C:\abc\def\ghi\jklmnopqrt.txt (long file name)
>
> to
>
> C:\zyx\wvu\tsrq\ ..... overwriting file xxxx.text
>
> I have been able to do this using a simple DOS batch file but this does
> not work with long file names.
>
> In windows terms I would like a short-cut on my desktop to an application
> which does this procedure on demand.
>
> Using a batch file was so simple is it complicated because of the use of
> lonf file names?
>
> Any advise or code greatfully received.
>
> Paul Smith
>
My System SpecsSystem Spec
Old 04-15-2008   #3 (permalink)
myself337


 
 

Re: Simple Batch Type Program

in VB you can do this:

Imports System
Imports System.IO


Module Module1

Sub Main()
Dim path As String = "c:\temp\filetocopy.txt" ' put the file you
want to copy here

If File.Exists(path) = True Then
Try

Dim path2 As String = "c:\temp\thecopiedfile.txt" ' put
where you want the file copied here
' Ensure that the target does not exist.
File.Delete(path2)
' Copy the file.
File.Copy(path, path2)
Console.WriteLine("{0} was copied to {1}.", path, path2)
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
Else
Console.WriteLine("{0} does not exist.", path)
End If

End Sub

End Module


"Paul W Smith" <pws@xxxxxx> wrote in message
news:OzUjVwymIHA.5660@xxxxxx
Quote:

>I would like to have a simple application that copies a file from one
>folder to another, changing the name of the file and overwriting the file
>in the destination location.
>
> Copy: C:\abc\def\ghi\jklmnopqrt.txt (long file name)
>
> to
>
> C:\zyx\wvu\tsrq\ ..... overwriting file xxxx.text
>
> I have been able to do this using a simple DOS batch file but this does
> not work with long file names.
>
> In windows terms I would like a short-cut on my desktop to an application
> which does this procedure on demand.
>
> Using a batch file was so simple is it complicated because of the use of
> lonf file names?
>
> Any advise or code greatfully received.
>
> Paul Smith
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
building simple c program .NET General
How to set errorlevel env variable properly from a simple batch file: Answered Vista General
Simple fax program? Vista print fax & scan
How to install Atl service program using batch file on vista Vista security
Batch File for ending program? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46