views:

102

answers:

1

Hi

I've been writing an application in MONO C# and I need help, my problem is my aplication has to load some photos from my server which is running windows XP and i need to know how i have to write the photo's path. i mean for windows is somthing like this.

Im using the IO class to load as stream and close inmediately to release the file

the code is something like this (this is in VB in C# is almost the same I just want to ilustrate my trouble):

Public Sub FotoProducto(ByRef whichPicturebox As PictureBox)

   Dim fsPicture As System.IO.FileStream
   Dim sPath As String

   'In windows I use this one and works fine
   "\\MyServer\PhotoFolder\picture.jpg"

   'in linux I supossed it would be:
   sPath = "smb://MyServer/PhotoFolder/picture.jpg"

   'I tried with local files and this code worked
   sPath = "/home/user/images/sample.jpg"

   'I don't know how to acces to files from others machines wich run WinXP
   'using the console, That's the reson why I think I'm writing wrong the path,
   'I've been looking in a lot of forums with no luck.

    Try
        fsPicture = New System.IO.FileStream(sPath , FileMode.Open, FileAccess.Read)
        Adonde.Image = Image.FromStream(fsPicture)
        fsPicture.Close()
        fsPicture.Dispose()
    Catch ex As Exception
        whichPicturebox.Image = My.Resources.Defaultt
    End Try
End Sub

I really thak you in advance

+2  A: 

Unless mono's IO library specifically supports dealing with Samba, I don't think this will work.

The correct way would be to first mount the samba share somewhere in the file system, then just use the direct path.

mount -t smbfs //MyServer/PhotoFolder /mnt/server (add samba options here)

Once you've done that, you can access the file as if it is part of the filesystem:

Public Sub FotoProducto(ByRef whichPicturebox As PictureBox)

   'path is mounted samba share
   sPath = "/mnt/server/picture.jpg"


End Sub

It's possible you could even have your mono application mount the network share when running.

MichaelM
Thank you let me check how I can do it and then I'll tell you what happend.Thank you :)
diego
It works, all I have to do is mount that folder at the system start up but there are a lot of forums about that.Thank you very much, people like you make easier the change to Linux
diego