c# - multiple file reading issue -


i having multiple text file different name in single folder . want read file 1 one -->> * read second file after finishing 1st . after reading should delete file directory .i able read single file . when trying read files in 1 shot giving error . how can use thread reading , delete file. file having same format .

my sample code :

        streamreader objreader = new streamreader("c:\codeo\testm.txt");         string sline="";         arraylist arrtext = new arraylist();          while (sline != null)         {             sline = objreader.readline();             if (sline != null)                 arrtext.add(sline);         }                     objreader.close();          foreach (string soutput in arrtext)             console.writeline(soutput);         console.readline(); 

for del :

             private void btndelete_click(object sender, eventargs e)              {               if (file.exists(fileloc))                {                  file.delete(fileloc);                }              } 

try code

directoryinfo di = new directoryinfo("c:\\codeo\\"); fileinfo[] fiarray = di.getfiles();  foreach (fileinfo fi in fiarray) {     streamreader objreader = new streamreader(fi.fullname);     string sline = "";     arraylist arrtext = new arraylist();      while (sline != null)     {         sline = objreader.readline();         if (sline != null)             arrtext.add(sline);     }     objreader.close();      foreach (string soutput in arrtext)         console.writeline(soutput);     console.readline();  } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -