Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:23:51+00:00 2026-05-31T19:23:51+00:00

Basically, i have a program that is given a 4 meg compressed file, it

  • 0

Basically, i have a program that is given a 4 meg compressed file, it has to decode this file into uncompressed ~ 100 meg, then compress it back into ~4 meg file. I need to store this intermediate 100 meg file somewhere on the drive (dont want to keep it in memory).

Program is written in C and will be executed on MS Windows 7. At the moment of uncompressing, no guaranteed folder (with write access) is given to the program (folder with source file might be read only and folder with target file might be not yet specified).

This has proven to be not an easy task:

1) I have read about a C function that creates a temp file that will disappear when closed or program is terminated. However, from what i understand it tries to make the file on disk C, in root directory, so this will obviously fail if user has no rights for that (which normal user doesnt)

2) I had an idea to use environmental/system variable TEMP and create a file there, BUT looking on a random Win7 PC which wasnt tweaked, i see that this variable points to c:/windows/temp, and that folder has specific rights for “users” – that is, they have rights to read, execute, create and write files, but not to delete them, check their attributes, etc. This means, i assume, that if program is ran with user privilleges, it will be able to make a file but not able to delete it, so the only way to “delete” it would be to open the file for writing and then close it, making it a 0 length file. This is also not desired, and i dont know how to query for system variables from C

3) So, basically, only idea i have right now is to make a function to open file that:

  • tries to create a temp file in the output dir, if possible
  • if failed, tries to create a temp file in input dir
  • if failed, tries to create a temp file in TEMP dir from system variable
  • if failed, tries to create a temp file in TMP dir from system variable

and a delete function that:

  • tries to remove() the file (by its name that is stored somewhere)
  • if failed, it tries to open the file for write, and close it, so it becomes a 0 byte file

Are there better ideas?

Any help is appreciated, thanks!

PS: Program must not use any external libraries like MFC or something, only built-in standart C functions

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:23:53+00:00Added an answer on May 31, 2026 at 7:23 pm

    GetTempPath

    Retrieves the path of the directory designated for temporary files.

    GetTempFileName

    Creates a name for a temporary file. If a unique file name is
    generated, an empty file is created and the handle to it is released;
    otherwise, only a file name is generated.

    These two provide you easy way to obtain a location and name for a temporary file.

    UPD: Code sample on MSDN: Creating and Using a Temporary File.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that has this code : #include<stdio.h> main(){ int input; char
I have a Java program that generates Java classes for my application. Basically it
So I have to do a program that basically tests that an XML text
My program is seemingly having a deadlock problem. Basically I have a class that
I have a program, written in C#, that when given a C++ or C#
I have a program that has many available options. For example a configuration option
Basically my problem is this: I have a CSV excel file with info on
I have been tasked to do a scheduling program in my company. Basically given
Basically, I want to have my program retrieve various variables from the hard drive
I have a gridview control in my c# program. Basically someone enters an email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.