.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Browsing all Images in Directory ... ?! asp.net & C#

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi every one ... How are you ??

OK ... I want to make album ... I try to make it using buttons( next & pre ) using imageButton control and variable (i)

So ... each next (++i) & pre ( --i) to show allimages in directory ("photo")

Here my code in C#  ::

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;
using System.Collections.Generic;

namespace iThinkerWebSite
    public partial class photos : System.Web.UI.Page

       // LinkedList<string> names = admin.getNames();
        DirectoryInfo dir;
        FileInfo[] files;
        static int i = -1;
        static int l = 0;

        protected void Page_Load(object sender, EventArgs e)
            dir = new DirectoryInfo(MapPath("photo"));
            files = dir.GetFiles();
            //l = (int)names.LongCount();
            l = files.Length;
            if (l == 0)
                Label2.Text = "No Photo to Display !!";
            Image2.ImageUrl = "images/ith.png";

View Complete Post

More Related Resource Links

The specified view is invalid error when browsing for images

Hello All, Currently using MOSS 2007 publishing site and using the CMS elements to publish content to the web.  One of our users is experiencing a strange problem whereby when they try to insert an image into the Sharepoint content editor using the Insert Picture functionality they get the following error when trying to browse to an image: The specified view is invalid.   at Microsoft.Sharepoint.SPViewCollection.get_Item(String strDisplayName) at Microsoft.Sharepoint.Publishing.Internal.States.AssetPickerDetailState.InitGridView(GridView grid) at Microsoft.Sharepoint.Publishing.Internal.States.AssetPickerDetailState.Configure(SMObjectList objectlist) at Microsoft.Sharepoint.Publishing.Internal.WebControls.SMObjectList.Handle_LoadCompleteEvent(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Page.OnLoadComplete(EventArgs e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Only one user is experiencing this problem, others are fine. Does anyone have ANY ideas what is causing this issue or how to fix it? Thanks

Show all images in a directory


I am trying to load every image *.png in a folder on my site. I simply want every image to be shown. One after the other, all on one page. Displaying a single image seems simple enough, but going through the entire directory is tough. How could I do this with minimum code using asp.net with vb as the language? 

Building a Searchable Phone Directory with Windows SharePoint Services

I want to continue to build out the intranet site we've started in our previous articles. A standard item in every intranet is a staff/employee list. Most companies implementing Windows SharePoint Services (WSS) are large enough to have a database that contains all employees. We will use the aggregation features of SharePoint to include data from this database into our intranet.

Images in WPF

How to create a Thumbnail of an Image. How to automatically crop an image. The following method allows you to automatically crop an image to it's content.

Reading and Writing Images From a Windows Mobile Database using UltraLite 10(C#)

Periodically I get a request for information on how to read and write binary data to a database running on Windows Mobile. If you search the Internet you can typically find examples that are available on Windows Desktops or allow you to read and write to a local file system. The problem is that it can take a bit of work to get this code to work on Windows Mobile accessing a database.

Ultimately you might be asking, why would I want to store and image in a database? Well in an environment where you synchronizing data between a local mobile database and a consolidated (central) database this can be extremely useful. Imagine if an insurance adjuster went to an accident scene, took a picture of a damaged car, loaded it into his Windows Mobile database and then replicated that image up to the Insurance headquarters for approval. All of this could be done in a very short period of time when using images in the database. Another good example might be a doctor who was waiting for a patient chart to become available. If you could store the image in a database this chart could be sent down to the doctor's device once it became available.

For this article I am not going to get into how to synchronize the images to and from a remote and central database as this is typically fairly straightforward when using a data synchronization technologies like MobiLink

Save images to SQL CE

Storing binary objects (such as image, office document etc.) into database is a little cumbersome when it comes to retrieval. Hence the most commonly accepted way is only store the file path in the database, and to store the documents on a file share.

Store and Display Images from MS Access Database Using C#

There is only the difference of coding syntax to stream the binary data of image content type to upload it into MS Access Database using C#/VB in ASP.Net 2.0

Namespaces required:-
using System.Data.OleDb;

OleDb is used to connect the web site forms with MS Access Database using Microsoft.Jet.OLEDB.4.0

Open File Print File Excel

Batch print many Excel files without having to open each one at a time. Quickly print mass amounts of xls files at once with this program. You must have Excel installed on your machine..

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or pasting into an application. 2D versions are also available:

Difference Btw Website vs Web application and Virtual directory in IIS 7


May i know what is the Differenc that they actually make in IIS7 .

Please tell me at a low level as i am still a novice in Asp.Net


Thanks in Advance.


Displaying Dicom images..........



Please guide

  1. How to display Dicom images in .net web apllications.
  2. How can i convert Dicom images to Jpeg.
  3. Can uplease provide me with a sample web application??

css and images gone on url rewriting


 I have a program which rewrites a url to a form     website.com/Default.aspx/name/articleid

The Program works fine ,but after URL rewriting my css sheet and images are gone . 

I am new to this and I have read that I should map my css and images to root. 

So ,I hav done some change to the path files of css and images but it stilll doesnt work .

Plz help me over this ...... 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TBV.aspx.cs" Inherits="TBV" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Article Page</title>
    <link rel="index" href="~/" title="Home" />
    <link rel="Stylesheet" media="screen,projection" type="text/css" href="~/css/main.css" />
    <link rel="stylesheet" media="print" type="text/css" href="~/css/print.css" />
    <link rel="stylesheet"

How to set SearchRoot Path in Active Directory in this scenario


How to set SearchRoot Path in Active Directory in this scenario:

Functionality: We have scenario that 1<sup>st</sup> hit one LDAP server with some 'fixed user name' &' fixed password ' and filter data with specific User name(which given by user) getting 'User dn'.

After that we hit Next LDAP server based on the 'User dn' getting from 1<sup>st</sup> server.

(So, in my case 1<sup>st</sup> LDAP server works like as Load balancing server but functionalitywise it is different)


active directory exception unusual behaviour


i have a small problem
i want user names from active directory for an auto completer type of service
the method is always throwing an exception 
"searcher.FindAll()' threw an exception of type 'System.DirectoryServices.DirectoryServicesCOMException' System.DirectoryServices.SearchResultCollection 

Active Directory and .NET: paging the search result

Hi everybody!

I have a question about Active Directory in .NET
For my project I need to fetch results from Active Directory search page by page, because later I would need to bind it to the pageable DataGrid.

I tried to use .NET library DirectoryServices for that, but paging provided by this library is transparent to the user and is used only to increase the efficiency of searching, when results are too big. I.e. I cannot tell the DirectorySearcher to give me first page, then the next or previous page, it returns me all resulting pages in one bundle.

However, what I need is to explicitely get page after page directly from the AD searcher and to be able to go at least one page forward or backward.

The solution with copying all results to the DataBase and then do the paging is not accepeted by the clent, since it is too inefficient. And since it's a Web app, I cannot keep results in memory either.

I found some hints about COM Interface, but I could not find good and detailed examples or explanations. I aslo found this line of code: DirectoryServices.Interop.IDirectorySearch.ExecuteSearch(), but I don't know which libraries should i add to be able to compile this code.

If somebody could help me out with that problem, any suggestion is welcome, 'cause this issue is eating me alive :)

Thank you!

Error on Display user's fullname using Active Directory in asp.net using vb.net



wi As System.Security.Principal.WindowsIdentity =  _System.Security.Principal.WindowsIdentity.GetCurrent()



Dim a As String() = HttpContext.Current.User.

Getting list of users reporting from specific Manager from Active Directory


Dear All,

I am have requirement like displaying all the user information reporting to specific manager from Active Directory.

Please help me regarding this.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend