tags:

views:

626

answers:

3

I need to count and check how much of some images is placed in folder od web server. Example- images get names from user_id, and on example I have user_id 27, and my images are: 27_1.jpg, 27_2.jpg, 27_3.jpg...

How to check and write to database this thing? Thanks

+4  A: 

Once you know your path you can use IO.Directory.GetFiles() method.

IO.Directory.GetFiles("\translated\path","27_*.jpg").Count()

will give you what you're looking for.

hometoast
A: 

Using the System.IO namespace, you can do something like this

public File[] GetUserFiles(int userId)
{
   List<File> files = new List<File>();

   DirectoryInfo di = new DirectoryInfo(@"c:\folderyoulookingfor");
   foreach(File f in di.GetFiles())
   {
      if(f.ToString().StartsWith(userId.ToString()))
         files.Add(f);
   }
   return file.ToArray();
}
WebDude
A: 

I'm beginer in ASP.NET (vb), and can you please give more detailed information? here begin while loop :>

while dbread.Read() dbread("user_id")

And how now to count images which I explained in POST up?

Wizard4U