Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C Win7 Delphi API
Hello,
 
I wrote a previewhandler for the explorer inside a dll.
The prevhost.exe has the same rights as the User.
I want to write a temporary file in the temporary directory
(or any other directory), but if I called the
function CreateFile() or fopen to write
or append anything to an existing file the function failed
with the error 5 - access denied.
 
Reading a file doesn't fail.
 
thank you
Posted 10-May-12 21:34pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

In the preview-handler - I can only write in a LocalLow-directory like
C:\Users\\AppData\LocalLow\
 
thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

"append": if a file is already in use, you'll likely get an access denied error (ok, in case of sharing it can work). Hence check that the file you want to write does not yet exist.
Are you sure that you write to the correct temporary directory? A user must not write to C:\Windows\Temp... Check with Windows explorer that you can create a file manually where you want to create your temporary file.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

As stated in solution #1, you can get this if the file is open with write or otherwise unshared access in another process. When you are developing software, it is common to write a version of your program which does not close files or terminate properly ... so an older errant version of your program could be holding the file open.
 
Several workarounds:
- Use a randomized filename to write/append to, so that you are opening a new file every time you run your program
- Reboot
 
Once you have your program debugged and working properly, change the logic to use the static filename.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 155
2 Peter Leow 115
3 Afzaal Ahmad Zeeshan 114
4 deepakdynamite 110
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,994
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100