Re: Simple program to copy files? how to?
- From: "James Hahn" <jhahn@xxxxxxxxx>
- Date: Wed, 17 Sep 2008 15:38:00 +1000
Have a look at the property Environment.UserName in the System namespace.
However, it might be simpler to use the Environment.GetFolderPath method with the enumerated parameter MyDocuments.
"Jason" <paul814@xxxxxxxxxx> wrote in message news:423ed811-4d31-415c-9487-0e4436665fc1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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...@xxxxxxxxx> wrote:
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...@xxxxxxxxxx> wrote in message
news:eb054fe4-3c7b-48e7-b662-6f8d45c8b028@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
.
- References:
- Simple program to copy files? how to?
- From: Jason
- Re: Simple program to copy files? how to?
- From: zacks
- Re: Simple program to copy files? how to?
- From: Jason
- Re: Simple program to copy files? how to?
- From: kimiraikkonen
- Re: Simple program to copy files? how to?
- From: Jason
- Re: Simple program to copy files? how to?
- From: James Hahn
- Re: Simple program to copy files? how to?
- From: Jason
- Simple program to copy files? how to?
- Prev by Date: Breitling Bentley Mark VI Platinum Steel Mens Watch P2636212-G6-973 Cheapest
- Next by Date: How to enumerate the logon, shutdown and duration times for a user
- Previous by thread: Re: Simple program to copy files? how to?
- Next by thread: Re: Simple program to copy files? how to?
- Index(es):