How to use Windows like filesystem action on Mac?

MatthieuDMatthieuD Member ✭✭
edited January 31 in Xamarin.Mac

Hello,

Here is my issue: I have an application using an old mono version (4.4.1) on an old ide (Xamarin 6.0.1) and some Windows internal calls such as FindNext or GetFileStats. These are InternalCall methods that I need to run my application.

I have updated everything to their last version, so I am now using Visual Studio for Mac 2017 and Mono 5.18.0.249 (with their associated XamMac.dll).
When I start the application, it says that FindNext or FindFirst method is not found anymore (Missing method exception) and that my mono build is sort of broken.

So how do I replace these methods?
I need methods that give me the stats of a file (if it's hidden, etc), ones that get the next file in line in a ptr, or the first in a folder, etc.
Such as found on Windows .Net.

If anyone knows I am all ears :smile:

If I was not clear, tell me, I will try to explain the situation better.

Best Answers

Answers

  • MatthieuDMatthieuD Member ✭✭

    Here is one internal call:

    [MethodImplAttribute(MethodImplOptions.InternalCall)]
    public extern static string FindFirst(string path, string pattern, out FileAttributes result_attr, out MonoIOError error, out IntPtr handle);
    

    I used what can be found here: https://github.com/mono/mono/tree/master/mcs/class/corlib/System.IO

    Here is one error when I launch the program:

    Exception: System.MissingMethodException
    Message: Attempted to access a missing method.
    StackTrace:   
    at (wrapper managed-to-native) System.IO.MonoIO.FindFirst(string,string,System.IO.FileAttributes&,System.IO.MonoIOError&,intptr&)
    

    And then I have the following errors:

    warning: cant resolve internal call to "System.IO.MonoIO::FindFirst(string,string,System.IO.FileAttributes&,System.IO.MonoIOError&,intptr&)" (tested without signature also)
    Your mono runtime and class libraries are out of sync.
    

    Maybe the simple solution is to use the new IO methods, but I don't know if there are any. Could not find them in the doc.
    To be noted that this program is years old and at the time mono was not advanced enough and didn't have IO methods, so we used this solution.

  • MatthieuDMatthieuD Member ✭✭

    Hello,

    I think this is what I am looking for. Not sure though.
    I don't really remember but I think years (4-6 years) ago, we could not use these methods. So now the engine runs with the old InternalCall methods which then worked properly. Maybe I can make it work with these ones.

    I will keep you updated if it does what I want. Thanks for your answer :smile:

  • MatthieuDMatthieuD Member ✭✭
    edited February 6

    @ChrisHamons said:
    Yeah, MethodImplOptions.InternalCall means you are invoke an internal method inside mono, which is subject to change. In the many versions since 4.4, they've apparently changed the implementation.

    What are you trying to accomplish? You may just need to use https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=netframework-4.7.2 and enumerate through them looking for whatever pattern you previous wanted.

    I recoded the engine to use the .net enumeration methods and it seems to work. Thank you for your answer :)

Sign In or Register to comment.