🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #632

Eliminacion de Archivos C#

#632
From: Pintamono
Date: Wed, 16 Apr 2008 20:09
50 lines
2485 bytes
Tengo un problema con la eliminacion de archivos en un directorio 
especifico.

Lo hago de la siguiente manera:

private static void EliminaProcesados() {
int i;
string[] strArrFiles;
string[] strArrDirectory;

strArrFiles=Directory.GetFiles(PathDirectorioProcesados);

strArrDirectory=Directory.GetDirectories(PathDirectorioProcesados);

if(strArrFiles.Length !=0 ||strArrDirectory.Length !=0) {
  try {
  if(strArrFiles.Length !=0) {
   for(i = 0; i <= strArrFiles.GetUpperBound(0); i++) { 
    FileInfo InfoFile = new FileInfo(strArrFiles[i]);
     DirectoryInfo InfoDir = new DirectoryInfo(PathDirectorioProcesados);
     if (InfoDir.Name=="Procesados") {
      if (InfoFile.Extension.ToLower()==".txt") {
        if (File.Exists(PathDirectorio+"\\"+InfoFile.Name))
     File.Delete(PathDirectorio+"\\"+InfoFile.Name);
        }
      }
     }
   }
  }
catch(Exception e) {
   throw new Exception("Error con el archivo "+e.Message);}
  }
}

El problema que siempre me arroja es este error: "The process cannot 
access the file [Ruta de mi Archivo] because it is being used by another 
process"

Una de las cosas que me di cuenta es que ocurre solo con el ultimo 
archivo del directorio ya que los primeros los mueve sin problemas.

Esta malo mi proceso de eliminacion o me falta algo por hacer?

Gracias.

PD:
PathDirectorioProcesados es la ruta de un directorio en done se 
encuentran los archivos que ya procese
PathDirectorio es la ruta en donde se encuentran los avisos procesados y 
sin procesar.
Technical Details
Message-ID: <fu5dko$hub$1@tucows.gtdinternet.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,8b9efdff5d7d86c9,start
X-Google-Attributes: gid1593cb,domainid0,public,usenet
X-Google-Language: SPANISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mail
From: Pintamono <Pintamono@NoMandeWeas.kk>
Newsgroups: chile.comp.programacion
Subject: Eliminacion de Archivos C#
Date: Wed, 16 Apr 2008 16:09:43 -0400
Organization: Gtd Internet S.A.
Lines: 50
Message-ID: <fu5dko$hub$1@tucows.gtdinternet.com>
NNTP-Posting-Host: kerberos.uno.cl
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: tucows.gtdinternet.com 1208367577 18379 200.27.224.101 (16 Apr 2008 17:39:37 GMT)
X-Complaints-To: usenet@gtdinternet.com
NNTP-Posting-Date: Wed, 16 Apr 2008 17:39:37 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)