How to move or copy a file between directories that have spa

Just starting out? Need help? Post your questions and find answers here.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to move or copy a file between directories that have

Post by Dude »

elfo116 wrote:i'm trying to copy a file from one directory like: C:\Users\PC 1\Desktop\ , but its impossible cause he have a space (PC""1), anyone can help me to solve this ?
It's as simple as this:

Code: Select all

source$="C:\Program Files\Internet Explorer\iexplore.exe"
target$="C:\Temp\"
CopyFile(source$,target$+GetFilePart(source$))
Note: This assumes that both the source file and target folder exist, and that you have (admin?) access to copy to the target folder.

Also, you're using GetCurrentDirectory() in your snippet. Hope you're not using that to get the location of your app? Because that's not what it's for, and may be why your copy is failing. You need to use something like this at the start of your code:

Code: Select all

Global appdir$=GetPathPart(ProgramFilename())
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: How to move or copy a file between directories that have

Post by Marc56us »

(off topic, but usefull)

A multi-user system is not limited to 'user' and 'administrator'.

To copy a file, you just need to have:
  • Read access to the source file (and directory)
  • Write access to the destination directory
  • Execution if you want to change the directory (yes, changing the directory is considered as an action)
You have to break the bad habit of asking for admin rights for everything else, otherwise there is no point in making multi-user systems with elaborate rights. And the slightest little virus can take advantage of this access (admin) even temporary.

:wink:
elfo116
User
User
Posts: 39
Joined: Sun Oct 12, 2008 9:50 am
Location: CADIZ

Re: How to move or copy a file between directories that have

Post by elfo116 »

Thanks to all !! :P
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to move or copy a file between directories that have

Post by Dude »

elfo116 wrote:Thanks to all !! :P
So... don't leave us hanging. What was the reason that your copy wasn't working? :)
Post Reply