code_junkie

Problem : Getting a mobile drive size using C# throws exception - Commented

Nov 13th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo;
  2. int iResult = 0;
  3. IntPtr Buffer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_INFO2)));
  4. iResult = CONAFileSystem.CONAFindNextFolder(hFindHandle, Buffer);
  5. while (iResult == PCCSErrors.CONA_OK )
  6. {
  7. FolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO2)Marshal.PtrToStructure(Buffer,typeof(CONADefinitions.CONAPI_FOLDER_INFO2));
  8. //......................... i got an error msg here as follows:
  9. // Error Messege:
  10. FatalExecutionEngineError was detected Message: The runtime has encountered a
  11. fatal error. The address of the error was at 0x7a0ba769, on thread 0x1294. The
  12. error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe
  13. or non-verifiable portions of user code. Common sources of this bug include
  14. user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
  15.  
  16. DriveInfo di = new DriveInfo("f"); //Put your mobile drive name
  17. long totalBytes = di.TotalSize;
  18. long freeBytes = di.TotalFreeSpace;
Add Comment
Please, Sign In to add comment