Reputation: 2087
I have an SDK sample in VC++ and i am writing code in c#. In VC++ sample they have used
struct _stat StatBuff;
When i checked the definition of _stat it is
#define _stat _stat64i32
They are using StatBuff as
unsigned int BuffSize = StatBuff.st_size + 8;
This code is intended to create a buffer for a browsed image file, next line is
ImageBuffer = (BYTE *)malloc( BuffSize );
i am wondering that how i can convert (StatBuff.st_size) in c#, i have searched a lot on internet but could not convert this piece of code. Can i use some alternate c# function.
Upvotes: 0
Views: 697
Reputation: 108975
The various _stat
functions are C/C++ library wrappers around underlying Win32 functions designed to make porting from Posix like OSs easier.
Using an offset like +8 is making assumptions about the internal layout of the _stat
type that could change.
All the information is available in the .NET FileInfo
type.
Upvotes: 1