如何从运行UBUNTU中的Mono应用程序的Win XP加载图片

时间:2009-09-29 00:18:09

标签: windows file ubuntu monodevelop

我一直在用MONO C#编写应用程序,我需要帮助,我的问题是我的应用程序必须从运行Windows XP的服务器加载一些照片,我需要知道如何编写照片的路径。我的意思是对于Windows来说就像这样。

我使用IO类作为流加载并立即关闭以释放文件

代码是这样的(这在C#中的VB中几乎是相同的,我只是想说明我的麻烦):

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

我提前告诉你了

1 个答案:

答案 0 :(得分:3)

除非mono的IO库专门支持处理Samba,否则我认为这不会起作用。

正确的方法是首先在文件系统中的某处安装samba共享,然后只使用直接路径。

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

完成后,您可以像访问文件系统一样访问该文件:

Public Sub FotoProducto(ByRef whichPicturebox As PictureBox)

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


End Sub

在运行时,甚至可以让你的单声道应用程序挂载网络共享。