views:

83

answers:

1

I need to copy "N" number of files from client to server with asp.net c #

I've done something like that, but it is useless because it takes only server addresses

Somebody help me .. Thanks ..!!!

  private void btnUpload_Click(object sender, System.EventArgs e)
  {
   string fileName = "";
   ArrayList List = new ArrayList();
   string _directory = Request.Url.Segments[1].Substring(0,Request.Url.Segments[1].Length-1);
   string TargetPathServer = "C:\\Inetpub\\wwwroot\\"+_carpeta+"\\Files\\Excell\\";
   string [] filePaths = Directory.GetFiles( @"D:\DOCUMENTOS\SIRM\Archivos","*.xls" );
   try 
   {
    if(Directory.Exists(TargetPathServer))
    {
     Directory.Delete(TargetPathServer,true);
     Directory.CreateDirectory(TargetPathServer);
    }
    else
     Directory.CreateDirectory(TargetPathServer);

    if (filePaths.Length > 0)
    {
          for (int i = 0; i <= filePaths.Length - 1; i++)
          {      
           string TargetPathServerFile = "C:\\Inetpub\\wwwroot\\"+_directory +"\\Files\\Excell\\";
           string TargetPathClient = filePaths[i];
           FileInfo info = new FileInfo(filePaths[i]);
           fileName = info.Name;
                             TargetPathServer = TargetPathServerFile + fileName;
           File.Copy(TargetPathClient,TargetPathServer);
           if (i == filePaths.Length - 1)
 }
         }
    else
    {
     uscMensaje.Text = ConfigurationSettings.AppSettings["strErrorNoFiles"].ToString();
     uscMensaje.DesplegarError();
    }
   }
   catch (Exception ex)
   {
    uscMensaje.Text = ex.ToString();
    uscMensaje.Desplegar();
   }
  }
A: 

r u using win client or asp.net to upload files. There are different stratgey for different plateform.

For asp.net ,you can use upload ile component. Please see below URL.

http://msdn.microsoft.com/en-us/library/aa479405.aspx This will let you files one by one.

If you can use silverlight in your application then see below URL

http://silverlightfileupld.codeplex.com/

With asp.net ,there is no direct way to upload multiple files simultaneously.

saurabh
I use asp.net to upload files
Andrei
Gracias ya encontre la solución con tú respuesta.
Andrei
Please accept the answer if you like.
saurabh