开发者

File Manipulating

Can anyone give me a solution for the below problem since am new to c sharp.

Am having a number of files in directory. Intially i开发者_如何转开发 want to load the first file without passing query string, with the first file there should have next file link. Once the next link button is clicked then only have to pass the query string.

how to pass the query string from second file to end of the file,

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=??

How to proceed this same upto reaching the end of the file?


You could use the index of the file for the next and previous button instead of the filename.

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜