You can use the ResolveClientUrl within your page code-behind:
var clientImageUrl = ResolveClientUrl("yourimagefolder/sampleimage.jpg");
或者,你可以使用虚拟卫生。 2. 巩固这一结果:
VirtualPathUtility.ToAbsolute("yourimagefolder/sampleimage.jpg")
In order to read all the files from a folder and then filter them by file name (your ID) you can use (use the System.IO namespace) :
DirectoryInfo directory = new System.IO.DirectoryInfo("c:YourFolder");
var allFiles = directory.GetFiles(".", System.IO.SearchOption.AllDirectories);
var fileFounds = from file in allFiles
where file.Name == "YourID"
select file;
foreach (var file in fileFounds)
{
//Build your image
}
EDIT: here s the vb.net version (I ve used a code converter, hope it worked well: )
Using ResolveClientUrl
Dim clientImageUrl = ResolveClientUrl("yourimagefolder/sampleimage.jpg")
Using VirtualPathUtility
VirtualPathUtility.ToAbsolute("yourimagefolder/sampleimage.jpg")
Reading files from directory
Dim directory As DirectoryInfo = New System.IO.DirectoryInfo("c:YourFolder")
Dim allFiles = directory.GetFiles(".", System.IO.SearchOption.AllDirectories)
Dim fileFounds = _
Where file.Name = "YourID"
Build your image
For Each file As var In fileFounds
Next