"pvong" <vonger@*dot*com> wrote in
news::
> I'm a newbie. Trying to do this in VB.NET
>
> On my server, I have a directory called c:\db\files\ and I have a
> whole bunch of pdf files in here. I want to do an onclick where the
> server checks to see if any of the files starts with the word "sharp".
> So I will have lots of files, but some files will look like this:
>
> sharp123.pdf
> sharp321.pdf
> sharp987.pdf
>
> I just want to look for the beginning of the word "sharp". If it
> finds a file starting with that, then I want it to do whatever. The
> directory is on the same server as my IIS and runing the site.
One hurdle to overcome here is the files are not in the web directories.
you can do this by creating a virtual directory to search the files
from. Otherwise, you will have to reduce some security setting to reach
the "outside" folder.
As for figuring out the files, you can loop through:
DirectoryInfo dir = new DirectoryInfo(filePath);
Regex regex = new Regex("^sharp");
foreach(FileInfo file in dir.GetFiles())
{
if(Regex.Match(file.Name).Success)
{
//file begins with sharp
}
}
You may have to vary the code a bit to get exactly what you want.
Outputting a PDF is a matter of streaming the bytes with a MIME type of
application/pdf.
Peace and Grace,
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************