Click here to Skip to main content
16,012,153 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Creating un-fragmented files Pin
AlexO23-Jul-03 9:15
AlexO23-Jul-03 9:15 
GeneralRe: Creating un-fragmented files Pin
David Crow23-Jul-03 9:15
David Crow23-Jul-03 9:15 
GeneralRe: Creating un-fragmented files Pin
John M. Drescher23-Jul-03 9:16
John M. Drescher23-Jul-03 9:16 
GeneralRe: Creating un-fragmented files Pin
Bob Stanneveld23-Jul-03 12:38
Bob Stanneveld23-Jul-03 12:38 
GeneralRe: Creating un-fragmented files Pin
Ryan Binns23-Jul-03 16:06
Ryan Binns23-Jul-03 16:06 
GeneralRe: Creating un-fragmented files Pin
Anders Molin23-Jul-03 13:41
professionalAnders Molin23-Jul-03 13:41 
GeneralRe: Creating un-fragmented files Pin
FlyingDancer23-Jul-03 15:04
FlyingDancer23-Jul-03 15:04 
GeneralRe: Creating un-fragmented files Pin
Ryan Binns23-Jul-03 16:05
Ryan Binns23-Jul-03 16:05 
Create the file, seek to the position corresponding to how long you want the file and call SetEndOfFile() to set the new size of the file:
hFile = CreateFile(...);
SetFilePointer(hFile, 1048576, NULL, FILE_BEGIN);  // 1MB file here
SetEndOfFile(hFile);
Of course, you'll need to perform error checking as well, and you'll need to change the value in SetFilePointer() to be the desired size of the file. I can't gaurantee that it will create unfragmented files (this is really up to Windows), but it's probably the most likely to if there is enough unfragmented space. Just keep in mind that the contents of the file are undefined, so you might want to go back and write over the file to initialise it. Some of the other guys have good suggestions, so try them as well Smile | :)

Hope this helps,

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: Creating un-fragmented files Pin
od@ananzi.co.za23-Jul-03 21:03
od@ananzi.co.za23-Jul-03 21:03 
GeneralAuto application logout Pin
Andrew Allen23-Jul-03 8:54
Andrew Allen23-Jul-03 8:54 
GeneralRe: Auto application logout Pin
John M. Drescher23-Jul-03 9:21
John M. Drescher23-Jul-03 9:21 
GeneralRe: Auto application logout Pin
Ryan Binns23-Jul-03 18:55
Ryan Binns23-Jul-03 18:55 
GeneralRe: Auto application logout Pin
John M. Drescher23-Jul-03 19:14
John M. Drescher23-Jul-03 19:14 
Generalqualifying enums ... Pin
Maximilien23-Jul-03 8:32
Maximilien23-Jul-03 8:32 
GeneralRe: qualifying enums ... Pin
Nathan Blomquist23-Jul-03 8:43
Nathan Blomquist23-Jul-03 8:43 
GeneralRe: qualifying enums ... Pin
QuiJohn23-Jul-03 8:55
QuiJohn23-Jul-03 8:55 
GeneralRe: qualifying enums ... Pin
John M. Drescher23-Jul-03 9:12
John M. Drescher23-Jul-03 9:12 
GeneralRe: qualifying enums ... Pin
QuiJohn23-Jul-03 9:20
QuiJohn23-Jul-03 9:20 
GeneralRe: qualifying enums ... Pin
Maximilien23-Jul-03 9:13
Maximilien23-Jul-03 9:13 
GeneralRe: qualifying enums ... Pin
Tom Archer23-Jul-03 9:49
Tom Archer23-Jul-03 9:49 
GeneralRe: qualifying enums ... Pin
Nathan Blomquist24-Jul-03 1:52
Nathan Blomquist24-Jul-03 1:52 
GeneralRe: qualifying enums ... Pin
Tom Archer24-Jul-03 2:08
Tom Archer24-Jul-03 2:08 
GeneralRe: qualifying enums ... Pin
User 665823-Jul-03 9:17
User 665823-Jul-03 9:17 
Generaldisplaying images Pin
Cyberizen23-Jul-03 7:55
Cyberizen23-Jul-03 7:55 
GeneralRe: displaying images Pin
John M. Drescher23-Jul-03 9:13
John M. Drescher23-Jul-03 9:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.