Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all...
here some php code is their.. but i want to c# code..
if any body knows pls let me know.
function ReadFolderDirectory($dir,$listDir= array())
{   
  $listDir = array();  
   if($handler = opendir($dir)) 
    {   
      while (($sub = readdir($handler)) !== FALSE)
         {    
         if ($sub != "." && $sub != ".." && $sub != "Thumb.db") 
            {   
              if(is_file($dir."/".$sub)) 
                {     
                $listDir[] = $sub; 
                }
elseif(is_dir($dir."/".$sub))      
           {      
               $listDir[$sub] = $this->ReadFolderDirectory($dir."/".$sub); 
                 }     
         }  
        }       
      closedir($handler);  
    }    
  return $listDir;    
 }
Posted
Updated 1-Aug-11 22:54pm
v2
Comments
Sergey Alexandrovich Kryukov 2-Aug-11 5:08am    
FolderDirectory? (Sigh...) :-)
--SA
komalilella 2-Aug-11 5:24am    
actually i have some directory structure like this:
newfolder
|_newfoder
|_file.txt
|_sample.txt
now i want to convert that directory structure into c#.if knows pls let me know.

1 solution

This is System.IO.Directory. There is one difficulty, so see the solution here: Directory.Get.Files search pattern problem[^].

See http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^].

—SA
 
Share this answer
 
Comments
komalilella 3-Aug-11 2:08am    
hi sakryukov...
u saw my directory structure above right...wat i will do means u can seralize to directory structure or converting that directory structure into json..
pls give any simple example...
iam new to json..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900