473,625 Members | 3,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple program to copy files? how to?

I want to create a simple program with Two buttons on the form.

BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\

BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\

And I would like to to not prompt if files exists, just overwrite...

thanks
Sep 16 '08 #1
10 4951
On Sep 16, 9:15*pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.

BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\

BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\

And I would like to to not prompt if files exists, just overwrite...

thanks
Like this thread about copying files by overwriting:
http://groups.google.com/group/micro...239d3c2?hl=en#

You can simply use,
My.Computer.Fil esystem.CopyFil e(sourcePath,de stPath,True)

...and make sure you have the right to copy to target UNC destination
not to get an exception like "access is denied".

For more info on detailed usage:
http://msdn.microsoft.com/en-us/libr...yf(VS.80).aspx

Hope this helps,

Onur Güzel
Sep 16 '08 #2
On Sep 16, 2:15*pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.

BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\

BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\

And I would like to to not prompt if files exists, just overwrite...

thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.
Sep 16 '08 #3
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)

I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.

also how do I do a %username% variable in the path so it only works
for current user?
On Sep 16, 3:27*pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15*pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\
And I would like to to not prompt if files exists, just overwrite...
thanks

I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.
Sep 16 '08 #4
"Jason" <pa*****@excite .comwrote in message
news:cf******** *************** ***********@f63 g2000hsf.google groups.com...
also how do I do a %username% variable in the path so it only works
for current user?
Isn't that automatic? Once the Filesystem takes over the OS handles the auth
based on the current user and not the App?

--
Phillip Windell
www.wandtv.com

The views expressed, are my own and not those of my employer, or Microsoft,
or anyone else associated with me, including my cats.
-----------------------------------------------------
Sep 16 '08 #5
On Sep 16, 11:07*pm, Jason <paul...@excite .comwrote:
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)

I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.

also how do I do a %username% variable in the path so it only works
for current user?

On Sep 16, 3:27*pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15*pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\
And I would like to to not prompt if files exists, just overwrite...
thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.- Hide quoted text -

- Show quoted text -
You're not specifying exact path of file,it seems you're trying to
copy folder with CopyFile function which is invalid, based on your
first post, you must include file name under the directory.
(sitemanager.xm l).

My.Computer.Fil eSystem.CopyFil e("C:\Documen ts and Settings\%USERN AME%
\Application Data\FileZilla
\sitemanager.xm l","\\drake\hom e\user\text\sit emanager.xml", True)

As the folder location in your last post is different than the one in
your first post, you can modify file location whatever you wish.

PS: If you intend to copy directories instead of file (had a suspicion
after your last post), you can use
"My.Computer.Fi leSystem.CopyDi rectory":
http://msdn.microsoft.com/en-us/libr...5e(VS.80).aspx

Hope this helps,

Onur Güzel

Sep 16 '08 #6
I have more than one user under documents and settings\ and
%username% does not work...

On Sep 16, 4:22*pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Sep 16, 11:07*pm, Jason <paul...@excite .comwrote:
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)
I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.
also how do I do a %username% variable in the path so it only works
for current user?
On Sep 16, 3:27*pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15*pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla\
And I would like to to not prompt if files exists, just overwrite....
thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.- Hide quoted text -
- Show quoted text -

You're not specifying exact path of file,it seems you're trying to
copy folder with CopyFile function which is invalid, based on your
first post, you must include file name under the directory.
(sitemanager.xm l).

My.Computer.Fil eSystem.CopyFil e("C:\Documen ts and Settings\%USERN AME%
\Application Data\FileZilla
\sitemanager.xm l","\\drake\hom e\user\text\sit emanager.xml", True)

As the folder location in your last post is different than the one in
your first post, you can modify file location whatever you wish.

PS: If you intend to copy directories instead of file (had a suspicion
after your last post), you can use
"My.Computer.Fi leSystem.CopyDi rectory":http://msdn.microsoft.com/en-us/libr...5e(VS.80).aspx

Hope this helps,

Onur Güzel
Sep 16 '08 #7
You replace %USERNAME% in the text string with the actual name of the user's
folder.

Or is the problem that you don't know how to find out the name of the user's
folder?

"Jason" <pa*****@excite .comwrote in message
news:eb******** *************** ***********@l64 g2000hse.google groups.com...
I have more than one user under documents and settings\ and
%username% does not work...

On Sep 16, 4:22 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Sep 16, 11:07 pm, Jason <paul...@excite .comwrote:
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)
I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.
also how do I do a %username% variable in the path so it only works
for current user?
On Sep 16, 3:27 pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15 pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from:
\\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n
Data\FileZilla\
And I would like to to not prompt if files exists, just overwrite...
thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.- Hide quoted text -
- Show quoted text -

You're not specifying exact path of file,it seems you're trying to
copy folder with CopyFile function which is invalid, based on your
first post, you must include file name under the directory.
(sitemanager.xm l).

My.Computer.Fil eSystem.CopyFil e("C:\Documen ts and Settings\%USERN AME%
\Application Data\FileZilla
\sitemanager.xm l","\\drake\hom e\user\text\sit emanager.xml", True)

As the folder location in your last post is different than the one in
your first post, you can modify file location whatever you wish.

PS: If you intend to copy directories instead of file (had a suspicion
after your last post), you can use
"My.Computer.Fi leSystem.CopyDi rectory":http://msdn.microsoft.com/en-us/libr...5e(VS.80).aspx

Hope this helps,

Onur Güzel
Sep 16 '08 #8
I guess I dont know how to find it out...I mean there are more than
one person that will use a computer, but this app will be put in All
Users Desktop, so anyone can run it.

so I want it to work when user1 is logged in as well as when user2 is
logged in.
so it would need to know when to use:
c:\documents and settings\user1\ Application Data
and
c:\documents and settings\user2\ Application Data

based on the user that is logged in
On Sep 16, 7:21*pm, "James Hahn" <jh...@yahoo.co mwrote:
You replace %USERNAME% in the text string with the actual name of the user's
folder.

Or is the problem that you don't know how to find out the name of the user's
folder?

"Jason" <paul...@excite .comwrote in message

news:eb******** *************** ***********@l64 g2000hse.google groups.com...
I have more than one user under documents and settings\ * *and
%username% does not work...

On Sep 16, 4:22 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Sep 16, 11:07 pm, Jason <paul...@excite .comwrote:
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)
I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.
also how do I do a %username% variable in the path so it only works
for current user?
On Sep 16, 3:27 pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15 pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from:
\\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n
Data\FileZilla\
And I would like to to not prompt if files exists, just overwrite....
thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter, a
boolean that specifies to overwrite or not.- Hide quoted text -
- Show quoted text -
You're not specifying exact path of file,it seems you're trying to
copy folder with CopyFile function which is invalid, based on your
first post, you must include file name under the directory.
(sitemanager.xm l).
My.Computer.Fil eSystem.CopyFil e("C:\Documen ts and Settings\%USERN AME%
\Application Data\FileZilla
\sitemanager.xm l","\\drake\hom e\user\text\sit emanager.xml", True)
As the folder location in your last post is different than the one in
your first post, you can modify file location whatever you wish.
PS: If you intend to copy directories instead of file (had a suspicion
after your last post), you can use
"My.Computer.Fi leSystem.CopyDi rectory":http://msdn.microsoft.com/en-us/libr...5e(VS.80).aspx
Hope this helps,
Onur Güzel
Sep 17 '08 #9
Have a look at the property Environment.Use rName in the System namespace.

However, it might be simpler to use the Environment.Get FolderPath method
with the enumerated parameter MyDocuments.

"Jason" <pa*****@excite .comwrote in message
news:42******** *************** ***********@x35 g2000hsb.google groups.com...
I guess I dont know how to find it out...I mean there are more than
one person that will use a computer, but this app will be put in All
Users Desktop, so anyone can run it.

so I want it to work when user1 is logged in as well as when user2 is
logged in.
so it would need to know when to use:
c:\documents and settings\user1\ Application Data
and
c:\documents and settings\user2\ Application Data

based on the user that is logged in
On Sep 16, 7:21 pm, "James Hahn" <jh...@yahoo.co mwrote:
You replace %USERNAME% in the text string with the actual name of the
user's
folder.

Or is the problem that you don't know how to find out the name of the
user's
folder?

"Jason" <paul...@excite .comwrote in message

news:eb******** *************** ***********@l64 g2000hse.google groups.com...
I have more than one user under documents and settings\ and
%username% does not work...

On Sep 16, 4:22 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Sep 16, 11:07 pm, Jason <paul...@excite .comwrote:
Here is what I tried:
My.Computer.Fil eSystem.CopyFil e("c:\Documen ts and Settings\user
\Application Data\Adobe\InDe sign\Version 5.0\InCopy TextMacros", _
"\\drake\home\u ser\text", True)
I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\u ser\text'.
also how do I do a %username% variable in the path so it only works
for current user?
On Sep 16, 3:27 pm, za...@construct ion-imaging.com wrote:
On Sep 16, 2:15 pm, Jason <paul...@excite .comwrote:
I want to create a simple program with Two buttons on the form.
BUTTON 1 - BACKUP PREFS
this will do the following:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n
Data\FileZilla
\sitemanager.xm l
to this location: \\drake\pvt\%US ERNAME%\FileZil la-Prefs\
BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from:
\\drake\pvt\%US ERNAME%\FileZil la-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERN AME%\Applicatio n
Data\FileZilla\
And I would like to to not prompt if files exists, just
overwrite...
thanks
I would use the FIle Class in the System.I namespace. Specifically,
the File.Copy method with the overload that takes a third parameter,
a
boolean that specifies to overwrite or not.- Hide quoted text -
- Show quoted text -
You're not specifying exact path of file,it seems you're trying to
copy folder with CopyFile function which is invalid, based on your
first post, you must include file name under the directory.
(sitemanager.xm l).
My.Computer.Fil eSystem.CopyFil e("C:\Documen ts and Settings\%USERN AME%
\Application Data\FileZilla
\sitemanager.xm l","\\drake\hom e\user\text\sit emanager.xml", True)
As the folder location in your last post is different than the one in
your first post, you can modify file location whatever you wish.
PS: If you intend to copy directories instead of file (had a suspicion
after your last post), you can use
"My.Computer.Fi leSystem.CopyDi rectory":http://msdn.microsoft.com/en-us/libr...5e(VS.80).aspx
Hope this helps,
Onur Güzel
Sep 17 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
4030
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are identical with which. Write a program that prints out which file are redundant copies. Here's the spec. -------------------------- The program is to be used on the command line. Its arguments are one or
5
1614
by: Ryan Waye | last post by:
I have looked extensively, and I have been unable to find commands that allow a C++ program to manipulate other files. How do I make C++ do simple things like copy and past files, and navigate directories? Also, where is a good command reference that I can use so I dont have to post these annoying questions? RW
5
7234
by: Rob Somers | last post by:
Hey all I am writing a program to keep track of expenses and so on - it is not a school project, I am learning C as a hobby - At any rate, I am new to structs and reading and writing to files, two aspects which I want to incorporate into my program eventually. That aside, my most pressing problem right now is how to get rid of the newline in the input when I use fgets(). Now I have looked around on the net, not so much in this group...
10
2367
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when there is such information to be displayed are they coming from imported files, database ? Where and how this type of information is stored ? What is the way to retrieve such information in order to display it in page ?
23
4142
by: Marco | last post by:
Could anyone please tell me why the program has the following error? I copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm ///////////////////////////////////////////////////////////////////// #include <dos.h> #include <string.h> #include <stdio.h> #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
6
2029
by: Jim M | last post by:
I've been distributing a fairly mature, very specific MS Access application to end users in small offices of colleges for several years now. This is a part-time venture and low volume operation- this is somewhat of a hobby for me. Many of my end users are computer phobic and get little support from their IT departments. It is a split database so the datafile gets put on the file server and the 3 different front ends get put on each local...
10
110200
true911m
by: true911m | last post by:
This is a simple walkthrough to get PyInstaller up and running. I decided to give PI a try, because it claims to be more selective about what it bundles into its executable files by default, and it also integrates UPX (Ultimate Packer for eXecutables) into the build process, if you have it installed. It also claims functionality on linux, as a bonus (I didn't test this). I highly recommend the UPX options, and will cover how to get it...
30
3510
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
5
2335
by: =?Utf-8?B?SmFwZQ==?= | last post by:
im writing a c# console application that copies files chosen from the windows explorer. I chose the files i want to copy and then from the (right key) menu chose my program. the program starts fine but passes an error that the file(s) are in use ny another user. This other user must be the windows explorer. Any workarounds to free the files from the windows explorer?
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.