write file in ram
Hello, I want to do the following:
Transfer some huge files (60MB) from pc a to pc c through pc b.
(PC A)->(PC B)->(PC C)
I want this to be done without that the files are written on the hard disk(of b), so they should stay in your ram (probably some hours, becouse a and c can't be connected simultaneously).
It should work for all types of files binary/ascii/...
How should I write/read to/from a "ramfile" ???
How to tranfer it ???
> I want this to be done without that the files are written on the hard disk(of b),
So what's so bad about the disk?
At least you don't have to re-transmit the file a->b if b reboots / loses power
> How should I write/read to/from a "ramfile" ???
By configuring your OS to create a ramdisk of some suitable size. How you do that depends on your OS, but as far as some C++ code is concerned, it's just another file.
thanks for your replie, but it's mainly to find out how it COULD be done, in c++, because it interest's me. If it's not possible to do this, I'll write to the disk.
look up file transfer, and on computer b have the files written to the ramdrive as Salem sugested, that is the onyway, ramdrives act just like Harddrives do.
Do note this has downsides; it creates another drive letter, and however much space you devote to this RAMdrive is no longer available to any programs. Allocate too little space and it's useless to you, too much and you could destabilize the system by effectively removing RAM. Also any program could use your RAMdrive.
And it typically requires a reboot to change RAMdrive parameters.
You might be able to use WinAPI calls to allocate memory that you tell it cannot leave physical memory (can't go through the swapfile). Unless you have very sensitive data that cannot be swapped to disk, though, I would just allocate the memory and let Windows decide how much to put in RAM/how much on the disk.