C# 图片浏览器
代码如何实现如下功能 :上一张、下一张、删除图片、 另存为、 放大 、 缩小。

解决方案 »

  1.   

    添加2个公共变量:
    public string[] Images;
    public int CurrentIndex = 0;
    选择路径后:
    Images = Directory.GetFiles(@"C:\Documents and Settings\Administrator\My Documents\Pictures", "*.*", SearchOption.AllDirectories);上一张:
    if (CurrentIndex == 0) CurrentIndex = Images.GetLength(0) - 1;
    pictureBox1.Image = new Image(Images[CurrentIndex]);下一张:
    if (CurrentIndex >= Images.GetLength(0)) CurrentIndex = 0;
    pictureBox1.Image = new Image(Images[CurrentIndex]);删除:
    File.Delete(Images[CurrentIndex]);
    //调用上一张,或者下一张。放大、缩小,用GDI+画图。另存:
    FileSaveDialog fsd = new FileSaveDialog();
    if (fsd.ShowDialog() == DialogResult.OK)
    {
        File.Copy(Images[CurrentIndex]), fsd.FileName);
    }
      

  2.   

    web中可使用jquery
    winform 就用imagelist结合oucturebox
    改变imagelist索引
    http://www.codeproject.com/KB/selection/ImageBrowser.aspx
    http://www.codeproject.com/KB/dotnet/multiImageViewer.aspx
      

  3.   

    如果希望在浏览器里实现上述功能,完全可以采用 JavaScript 来体现,这样也大大减轻了服务器的负担。