Solved

How to pick only aaaa*.pdf file in GetFiles() function, and how to add to Gridview.

Posted on 2012-04-10
2
354 Views
Last Modified: 2012-06-27
The following code displays all the file names.
1.How to pick the files name having the format as xxxxx_yyyy.pdf
here the xxxxx is being entered from Textbox t1.
2.What ever the resultset comes should be added to Gridview1.

DirectoryInfo dir = new DirectoryInfo(MapPath("Files/"));
        FileInfo[] files = dir.GetFiles();
        ArrayList listItems = new ArrayList();
        foreach (FileInfo info in files)
        {
            listItems.Add(info);
            Response.Write(info.ToString());
        }
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37831238
FileInfo[] files = dir.GetFiles(string.Format("{0}_yyyy.pdf", t1.Text));

if you don't care about characters after the underscore then use:

FileInfo[] files = dir.GetFiles(string.Format("{0}_*.pdf", t1.Text));
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37831248
ok
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question