StandardBearer
StandardBearer

Reputation: 55

Creating a file reference

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;
}

Upvotes: 3

Views: 170

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48230

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.

Upvotes: 3

Related Questions