0

我一直在用 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

我真的提前谢谢你

4

1 回答 1

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

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

于 2009-09-29T00:28:14.660 回答