Re: Simple program to copy files? how to?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have more than one user under documents and settings\ and
%username% does not work...

On Sep 16, 4:22 pm, kimiraikkonen <kimiraikkone...@xxxxxxxxx> wrote:
On Sep 16, 11:07 pm, Jason <paul...@xxxxxxxxxx> wrote:



Here is what I tried:
My.Computer.FileSystem.CopyFile("c:\Documents and Settings\user
\Application Data\Adobe\InDesign\Version 5.0\InCopy TextMacros", _
"\\drake\home\user\text", True)

I get a: Could not complete operation since a directory already exists
in this path '\\drake\home\user\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...@xxxxxxxxxxxxxxxxxxxxxxxx wrote:

On Sep 16, 2:15 pm, Jason <paul...@xxxxxxxxxx> wrote:

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\%USERNAME%\Application Data\FileZilla
\sitemanager.xml
to this location: \\drake\pvt\%USERNAME%\FileZilla-Prefs\

BUTTON 2 - RESTORE PREFS
this will do the opposite:
copy sitemanager.xml file from: \\drake\pvt\%USERNAME%\FileZilla-Prefs
\ and put it here:
Copy C:\Documents and Settings\%USERNAME%\Application 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.xml).

My.Computer.FileSystem.CopyFile("C:\Documents and Settings\%USERNAME%
\Application Data\FileZilla
\sitemanager.xml","\\drake\home\user\text\sitemanager.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.FileSystem.CopyDirectory":http://msdn.microsoft.com/en-us/library/2swy9y5e(VS.80).aspx

Hope this helps,

Onur Güzel

.


Quantcast