Tech Support > Microsoft Windows > Development Resources > Moving files, changing permissions
Moving files, changing permissions
Posted by Tom on May 6th, 2005


Hello,

I'm working on an application that downloads files into a
temporary directory, and then moves them into their final
location. However, using MoveFile means that they keep
their original permissions from when they were created.
This can be a problem if the final directory is a network
share, because the files won't have the permissions to
allow access via the network.

What is the simplest way to force a file in a folder to
pick up the default permissions for files created in that
folder? I think I could just create a new file and use
Get/SetFileSecurity() to copy the permissions, but I'd
rather not create any new files if I can avoid it. Any
other ideas?

Thanks,

Posted by news.x-privat.org on May 9th, 2005


Have you considred copying the file and then delete the original if
successful? I think that will cause the file to inherit the directory access
rights.

--

Ted Ferenc
This address used is maintained only for newsgroup posting.
Mail sent there may not be read by me for several days.
"Tom" <tomkleinpeter@gmail.com> wrote in message
news:1115402761.496132.289520@o13g2000cwo.googlegr oups.com...


Posted by Tom on May 9th, 2005


Well, there are 2 problems with that: performance and disk usage.
The files can be several gigabytes, and making a copy of those
takes a long time and uses a lot of disk space.

Thanks,
Tom

Posted by Ted Ferenc on May 9th, 2005


Fair enough!

In that case use movefile but on the directory you are moving from set its
atributes to be the same as the destination directory!

I admit this is very crude, but it works!

--

Ted Ferenc
This address used is maintained only for newsgroup posting.
Mail sent there may not be read by me for several days.
"Tom" <tomkleinpeter@gmail.com> wrote in message
news:1115646949.979468.51660@f14g2000cwb.googlegro ups.com...


Posted by Tom on May 10th, 2005


Unfortunately, I don't always move files to the same folder I've
downloaded them. The different folders can have different
permissions.

Thanks,

Posted by Ted Ferenc on May 12th, 2005


As you no doubt appreciate I have just had the same problem, but in a 3rd
party SDK so I am stuck with it, until they change the SDK.

But fortunately they use the temp dir and move the file from there.

--

Ted Ferenc
This address used is maintained only for newsgroup posting.
Mail sent there may not be read by me for several days.
"Tom" <tomkleinpeter@gmail.com> wrote in message
news:1115732075.340767.323110@f14g2000cwb.googlegr oups.com...



Similar Posts