我一直在用 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
我真的提前谢谢你