English 中文(简体)
• 如何从Ap.net(vb.net)的夹处获取具体档案
原标题:how to get specific files from a folder in asp.net (vb.net)

I want to get all the files from a folder using DirectoryInfo, how can i perform check and get all the images from the folder, For checking i want to pass a productid as all the images are saved with their productids, for instance a product (bmw) has a product id 100 ,

Any ideas or tutorials of how to workout this. Your help will be appreciated .

最佳回答

在使用目录时,你可以使用搜索过滤器。 带野心的鱼类

Dim files As String() = Directory.GetFiles("c:", string.Format("{0}*.jpg", productId)

* 在搜索引擎中,是一张野心。 任何与产品Id和末端的第一部分相对应的过滤标准将符合过滤标准。

This function will return a list of strings of all the matching files. In the result you will have the full path to each file.

The filter above would match all of these if the productId is set to "101": 101_1.jpg 101_10.jpg 101_100.jpg

but would not match because the first part of the criteria is not fullfilled then. 100_1.jpg

问题回答

as you know you will be passing the productid, and filename is a string so you can always check filename.substring(0,3)== your productid if it is same then the correct images for that proudct id are saved





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签