有没有人能给我一个解决下面这个问题的方法,因为我是新手。
我在目录中有许多文件。最初我想加载第一个文件而不传递查询字符串,第一个文件应该有下一个文件链接。单击next链接按钮后,只需传递查询字符串。
如何将查询字符串从第二个文件传递到文件末尾,
DirectoryInfo oImageFolderInfo = new DirectoryInfo(this.ImagePath);
FileInfo[] oFileList = oImageFolderInfo.GetFiles("*.*");
string fileName=string.Empty;
if (Request.QueryString["filename"] != null)
{
fileName=(Request.QueryString["filename"]);
}
else
{
fileName = oFileList[0].Name;
}
HtmlImage imag = new HtmlImage();
imag.Src = Url + fileName;
HtmlAnchor nextAnchor = new HtmlAnchor();
nextAnchor.Href=??
nextAnchor.InnerText = "Next>>";
HtmlAnchor prevAnchor = new HtmlAnchor();
prevAnchor.Href=??
如何进行同样的操作直到文件的末尾?
发布于 2011-03-25 19:00:49
您可以将文件的索引用于“下一步”和“上一步”按钮,而不是文件名。
DirectoryInfo oImageFolderInfo = new DirectoryInfo(this.ImagePath);
FileInfo[] oFileList = oImageFolderInfo.GetFiles("*.*");
string fileName=string.Empty;
int index = 0;
if (Request.QueryString("i") != null)
index = Request.QueryString("i");
fileName = oFileList[index].Name;
HtmlImage imag = new HtmlImage();
imag.Src = Url + fileName;
if (index > 0)
prevAnchor.Href = String.Format("{0}?i={1}", Url, Index - 1);
if (index < oFileList.Count(
nextAnchor.Href = String.Format("{0}?i={1}", Url, Index + 1);
https://stackoverflow.com/questions/5430927
复制相似问题