Can't open a file for writing in the ProgramData folder

Hi,
I have a simpe text file in the ProgramData directory that I need both to read and write to.
SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, SHGFP_TYPE_CURRENT, userpath);
PathAppend (userpath, TEXT("Testfolder/gnsh.dat")); licensefile = _wfopen(userpath, L"r+"); 
However, the only way I have been able to open the file both in read and write modus, is to run the program as an administrator. But this is not a practical solution. The question is then if there is a way  to open this file in both moduses when running
the program in the normal way, not as an administrator.
Thanks in advance.

Hi,
Thank you for youre answer, that was very useful. It helped me find the solution. The file I wanted to edit was downloaded with Inno Script Studio, which by installation changed the attributes of the file to none writable. So simple by setting a parameter
in this scripture I was given write access.
Best regards

Similar Messages

  • "Attempt to open locked file for writing, Result Code = -54" when importing

    I get this error box when importing audio files into a logic session over my network.
    +Attempt to open locked file for writing+
    +Result Code = -54+
    The finder is capable of copying the files over to the local machine, at which point I can successfully import them into my local logic session, but Logic is incapable of doing the same. Strange and annoying.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • Can't open '/dev/rdisk1' for writing (Resource busy)

    I got a Macbook Pro, install win7 on boot camp. When I wanted to resinstall win7, I accidently click on Recover button and it deleted all my partitions and become one, which run Mac OS. I tried to recover my data partition. On google, I found some guy do it with 'pdisk' command. I followed steps but when I tried to use pdisk:
    sudo pdisk /dev/rdisk0
    and use command 'i':
    i got a message: can't open '/dev/rdisk0' for writing (Resource busy)
    So I borrowed a Mac, connected it with my Macbook through FireWire, and set my Mac in 'Target Disk Mode' and use pdisk again:
    sudo pdisk /dev/rdisk1
    when i use command 'i', i still got the message:
    can't open '/dev/rdisk1' for writing (Resource busy).
    Can anyone know what is this problem? Do I need to extract my hard disk from my Mac?
    Please tell me about it!
    Thanks!
    vanpn
    P/S: this is the link I read about recover partition: http://perrohunter.com/index.php/blog/2011/06/repair-a-mac-os-x-hfs-partition-ta ble

    Hi,
    Thank you for youre answer, that was very useful. It helped me find the solution. The file I wanted to edit was downloaded with Inno Script Studio, which by installation changed the attributes of the file to none writable. So simple by setting a parameter
    in this scripture I was given write access.
    Best regards

  • I can't open swf files for schoolwork. Installed VCL, Flip4Mac and Adobe flash and shockwave players. Can get white screen with connection erro message with adobe flash player. Help me!

    i can't open swf files for schoolwork. Installed VCL, Flip4Mac and Adobe flash and shockwave players. Can get white screen with connection erro message with adobe flash player. Help me!

    Apple dropped playback support for .swf formats in QuickTime almost ten years ago.
    Adobe Flash Player is the only way to view them.

  • Pro Tools 11 Attempt to open locked file for writing (-54)

    I am able to download Pro Tools 11 (includes HD) Pro Tools_11_0_2_Mac_80450.dmg to my Mac Mini, running 10.8.5.  However, when I run it and start Pro Tools 11, it gives me the error "Attempt to open locked file for writing (-54)".
    If someone could help me, I would appreciate it immensely.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • Opening existing file for writing

    Hey how do I open an existing file for writing. For example I want to just add one more line to a file after it has been closed but I don't have the reference to the FileWriter / BufferedWriter object. So I have to tell the directory maybe but how do I open it and start writing to it at the end.
    Thanks.

    You just create a new File Object<br>
    File f = new File("c:/foo.txt");<br><br>
    Then you can read or write to that file with FileReader or FileWriter<br>
    FileWriter fw = new FileWriter(f);<br>
    fw.write();<br><br>
    If you want to append sth. to a file I would recommend RandoAccessFile<br>
    RandomAccesFile raf = new RandomAccesFile(f, "rw")<br>
    Now you can get the length of the file and set the pointer to the end <br>
    raf.seek(raf.length());

  • FileNotFoundException thrown when opening a file for writing from EJB

    Hi,
    I know it is against EJB rules that access file IO from EJB. However we have a legacy system to working with and we need to generate a text file on file system.
    Weblogic (we are using 10.3) allows open a file for read from EJB. When we tried to open a writer like below:
    BufferedWriter writer = new BufferedWriter( new FileWriter(fileName, false));
    FileNotFoundException was thrown from the native method of open. The fileName is an absolute path and permission is properly set. The same piece of code can execute correctly in a test application with same filename.
    Does anyone know how to achieve this or whether Weblogic just forbids this kind of output access?

    Sorry guys. Just double-checked the source code and found out a bug produced wrong filename, the filename was surrounded by "", so FileNotFoundException is a correct result.
    Weblogic does allow read/write external file.

  • Can't open a file with spaces on the filename.

    Lets say I have a file:
    /home/orv/Open - Me - Please.txt
    When I double click to open that file with any program, the result is something like this:
    "Unable to find /home/orv/Open%20-%20Me%20-%20Please.txt"
    I'm not sure what to call that process of converting the file name so I've been unable to google it up to find a fix or a way to change the behavior of the file manager.
    I've checked the settings in Nautilus and nothings there. Any clues? Thank you!
    Last edited by orv (2007-12-14 23:11:59)

    I tried removing everything in my home directory to erase all settings, still the same problem.
    I tried using a different file manager and still the same problem.
    Here's another example of my problem and its quirks:
    Lets say I have a file called:
    /home/orv/I am a Movie.avi
    In nautilus or thunar, double-clicking that file so I can play it with Mplayer will give an error:
    Failed to open file:///home/orv/I%20am%20a%20Movie.avi
    However, when I drag and drop using the file manager into Mplayer, it works.
    So my problem is this automatic conversion of whitespaces into the %20 which I don't know how to turn off.

  • HT3042 I can't find any file exchange icon in the utilities folder

    I can't find the Bluetooth File Transfer icon in the utilities folder on my iPhone

    It's not supposed to be on your iPhone. That application is for Macs.
    iPhone's do not support file transfers over Bluetooth. There are some apps in the AppStore that can do it to the same app running on another iOS device, but not to non-iOS devices.

  • Can't open .mov files for iMovie editing; can't even view in QuickTime, etc

    Our band recently had a videographer record our performance using two panasonic hd cameras: AG-HVX200 and HPX170. Both were set to hd 720 X (?) at 30 fps.
    All files were saved as .mov files.
    We can't see them at all. We were told that they were designed to be opened in Final Cut Pro (which we told him not to do).
    We do have Final Cut Express, but neither FCE nor iM allows us to select the files ("grey'ed" out).
    Can someone please help us understand how to open these files? Do we need a specific codec?
    Thanks much.

    I am no expert on DVC Pro HD, but here is what I found out.
    HD compression format by Panasonic. 
    Similar compression type to DV 25 but uses a higher bit rate up to 100 Mbit/sec,  depending on 
    the specific HD format being recorded. Highly popular format because of its lowe r bit rates, and 
    incredible resolution considering how highly compressed the format is. 
    This format is very popular as an acquisition format used with Panasonic's Varic am camera as well>as several Panasonic cameras that record to P2 card systems. A lso used heavily to convert higher->end HD formats into a high quality offline e diting format. Uses component recording, DCT 
    compression at approx. 7:1 (intraframe), 4:2:2 color sampling, 8->bit depth and  up to 8 audio channels. 
    1080 formats record at 1280x1080, 720 formats record at 960x720. At 1080p, frame  rates include>23.98, 24, 25 fps. At 1080i, frame rates include 25, 29.97, 30 fp s. At 720p, frame rates include 
    23.98, 24, 25, 29.97, 30, 59.94, 60 fps.
    Source: Moviola
    I agree that you want AIC not DV. AIC is a 4:2:0 codec so you will lose some quality, but it is your best option without buying FCP.
    Message was edited by: AppleMan1958
    Message was edited by: AppleMan1958

  • Can't open exe file for spy master pro and I jail broke my phone and still having problems

    If any one know how to open excuiable file (exe) file after I jail broke my phone cause I
    Bought I soft ware that is call spy master pro. My 15yr son mother past away few months ago
    And I want to watch him and make sure he stays on right path.

    Already asked and answered ...
    See https://discussions.apple.com/thread/4848876?tstart=0

  • Can't open Illustrator file - "does not have the correct number of operands..."

    Right off the bat - Mac, 10.6.8, Illustrator CS4. I've seen different variations of this "...correct number of operands..." error on these boards, with fonts and other things as the culprit, but I haven't come across this specific issue yet. If someone has seen something along these lines please let me know.
    I work for a small design agency that uses Illustrator CS4 on a consistent basis. We have had an ongoing issue where random files that had been working fine will sporadically become corrupt, causing us to have to use the Document Recovery Mode and then edit the file in a text editor to fix the problem which does work for this issue flawlessly, other than the headache of having to do this repeatedly.
    Our workflow is such that we use a local area storage RAID which everyone uses to access the same client files. These client files are all in a series of nested folders we employ to keep all our separate client's work separate. The error arises when certain images are placed into a document, then the document is saved and closed. Upon trying to reopen the file we get an error message like this:
    Where the string "/CR0050_ret.psd" is the filename of the offending image. Basically what has happened is that in the actual code for the document, there is a string that starts as "%%IncludeFile....." which specifies the file's pathway on the local area storage we use. The last segment of that string is the image's filename, which has gotten returned to the next line down, and now the program cannot interpret that line in the code, so it cannot properly open the file. The file will open but only the content that is above the offending IncludeFile string is visible.
    (client information blurred out)
    This does not happen to all the "%%IncludeFile" strings in the document, and does not happen for all images on our local area storage. We know how to fix the problem through the Document Recovery mode and then editing the text. Once we return the filename portion of the code back up to the proper line, and save the file in the text editor, the file will open in Illustrator and show all the information contained within properly. However, if you save the file out again without making any changes, the same errors will propagate throughout the file's code again, and become unreadable prompting another document recovery. Insert endless cycle here.
    What we would like to try and find out is why is this happening, so we can prevent it from happening in the future. Is the image nested too far down in the hierarchy of folders? Are there too many characters in the file pathway string? What can we do to keep this from happening moving forward?
    I know that an easy answer is to copy the files over locally to our hard drives, and work from there, but this is not a very efficient way to work, as we are all collectively working on different files, utilizing common image resources. We like to keep one set of images so there is no duplication that may lead to the wrong image being sent out - "Oh you sent John's version? You should have sent Molly's version of the image for that file"
    We also downloaded the trial version of Illustrator CS6 to see if an upgrade would work wonders, but it does not, the problem persists when saving a recovered file in CS6.
    Any thoughts? Thanks in advance.
    ABK

    In Illustrator it is generally not a good idea to read and write directly to and from a server: http://helpx.adobe.com/illustrator/kb/illustrator-support-networks-removable-media.html
    If you really think you need to do it, then check your network thoroughly.

  • I just upgraded to Firefox 4 on my new MacBook Pro and can't open pdf files, or sometimes only the first page will open. Can anyone help?

    There are no more details. The files either open to a blank page or the first page only.

    Me thinks you have tried to connect to a shortcut folder and not a genuine folder.
    Note Mac OS X in Mac OS X 10.4 has 3 popular folder shortcut locations:
    The leftmost column of the Finder window.
    The horizontal toolbar on the top of the Finder window
    The translucent bar which can be anchored on the side or bottom of the screen known as the Dock. These are not true folder locations, but only locations for shortcuts. When you click on a folder for a volume that is not mounted, or is a folder which was deleted it will behave in this fashion. Often if you click on it the right fashion, it will change to a question mark.
    In addition if it is an alias to an existing folder that has no contents, it will behave this way from the three shortcut locations.
    If you right click instead of the left click a folder, it may think you want to do something to the folder which you can't do. Make sure your mouse button functions properly as a Primary button on Apple menu -> System Preferences -> Keyboard and Mouse.
    Also make sure Universal Access is not turned on as it too can cause funny behavior in the mouse click actions, in Apple menu -> System Preferences -> Universal Access.

  • Can you only share files that reside in the public folder

    We have a few macs on our home network, and sometimes we share files.
    But when I want to copy a file from say my wife's computer which is named "Jane's mac", when I connect, I only can copy a file from her shared folder.
    Is there any way to open up the files so they can be shared with everyone on the network, or do we have to put them in the shared folder.
    Obviously security is an issue as I wouldn't want anyone to be able to get access to our home folders, but just out of convenience, I was curious.
    Thanks.
    Russell

    I should add that this is on the computer on which you want to share from. Then you can set whatever user(s) that are set up on that computer that you want to be able to access those shared folders. The user can be one with an account on the computer from which you're sharing, or in the Address Book on that system, or some other places. Then from the other computer you connect using the user name and password you've allowed access.
    Hope this helps.

  • I can't open a file, when I try the following messagge appears: "There was an error opening this document. The file is damaged and could not be repaired."

    But I tried from a different computer and it worked there.

    What is your operating system?  Reader version?

Maybe you are looking for