Usuário com melhor resposta
Upload com FTP

Pergunta
-
Boa tarde, estou tentando fazer um upload através de um FTP enviando um arquivo zip, porém minha aplicação gera sempre esse erro:
The requested URI is invalid for this FTP command.
Segue meu código:
string endereco = ConfigurationSettings.AppSettings.Get("ftp") + ""; string arquivo = @"C:\Documents and Settings\caminho\Meus documentos\CMA\" + cdEnvio.ToString().PadLeft(6, '0') + ".zip"; System.Net.WebClient cliente = new System.Net.WebClient(); System.Net.NetworkCredential credencial = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings.Get("usuario").ToString(), ConfigurationSettings.AppSettings.Get("senha").ToString()); cliente.Credentials = credencial; try { cliente.UploadFile(endereco, arquivo); } catch (Exception ex) { throw new Exception(ex.Message); }
O que pode ser?
Alguém pode me ajudar?
Muito obrigado !
Respostas
-
Resolvi o problema só alterei:
string arquivo = @"C:\Documents and Settings\caminho\Meus documentos\CMA\" + cdEnvio.ToString().PadLeft(6, '0') + ".zip"; string endereco = ConfigurationSettings.AppSettings.Get("ftpCma") + cdEnvio.ToString().PadLeft(6, '0') + ".zip";
- Marcado como Resposta Progamador.C terça-feira, 19 de abril de 2011 17:52
Todas as Respostas
-
Amigo a variável endereco está pegando a URI ftp correta ? vc ja verificou se ela está no formato aceito, por exemplo : ftp://localhost/arquivo.txt ?
Olavo Oliveira Neto
http://olavooneto.wordpress.com
Se for útil marque como resposta e faça um Developer feliz :) -
Resolvi o problema só alterei:
string arquivo = @"C:\Documents and Settings\caminho\Meus documentos\CMA\" + cdEnvio.ToString().PadLeft(6, '0') + ".zip"; string endereco = ConfigurationSettings.AppSettings.Get("ftpCma") + cdEnvio.ToString().PadLeft(6, '0') + ".zip";
- Marcado como Resposta Progamador.C terça-feira, 19 de abril de 2011 17:52