Page 2 of 2

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

Posted: Fri Mar 22, 2019 8:30 am
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())

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

Posted: Fri Mar 22, 2019 10:26 am
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:

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

Posted: Mon Mar 25, 2019 1:25 pm
by elfo116
Thanks to all !! :P

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

Posted: Mon Mar 25, 2019 1:28 pm
by Dude
elfo116 wrote:Thanks to all !! :P
So... don't leave us hanging. What was the reason that your copy wasn't working? :)