Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a file reference

Tags:

c#

Is it possible to create an object that simply holds a file (either by reference or by memory). Then, if you want to move it via FTP or other means you can use that file reference.

private [some object type] CreateFileObject() {
    [some object type] FileObj = new [some object type];
    return FileObj;
}
like image 750
StandardBearer Avatar asked Mar 24 '26 14:03

StandardBearer


1 Answers

At least three possibilities.

The file name of string type. You have it and can use it to do whatever with the file.

The native file handle of IntPtr type. I doubt it is as useful as it sounds as only native API works at handle level.

The reference to the stream of Stream type. Possibly mostly useful. You can read the content, reread and use any decorator streams on it (network streams, zip streams etc.). That would be my choice as it leverages the fact that the Base Class Library uses streams widely.

like image 179
Wiktor Zychla Avatar answered Mar 27 '26 04:03

Wiktor Zychla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!