J'ai un fichier situé à http://10.1.10.211:8600/CardsPro+.exeRécupérer fichier à partir du serveur IIS avec caractère spécial Nom C# .Net
Et je suis en train de le récupérer avec le code suivant, mais obtenir l'erreur "Erreur HTTP 404.11 - Not Found "
private WebClient webClient;
private BackgroundWorker bgWorker;
private string tempFile;
private string md5;
internal string TempFilePath
{
get { return this.tempFile; }
}
internal UpdateInfoDownloadForm(Uri location, string md5, Icon programIcon)
{
InitializeComponent();
if (programIcon != null)
{
this.Icon = programIcon;
}
tempFile = Path.GetTempFileName();
this.md5 = md5;
webClient = new WebClient();
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
bgWorker = new BackgroundWorker();
bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork);
bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BgWorker_RunWorkerCompleted);
try
{
string strend = location.ToString().Substring(location.ToString().LastIndexOf('/')+1);
string strstart = location.ToString().Substring(0,location.ToString().LastIndexOf('/')+1);
strend = System.Web.HttpUtility.UrlEncode(strend);
Uri locn = new Uri(strstart+strend);
webClient.DownloadFileAsync(locn, this.tempFile); **//It fails here**
}
catch(Exception ex)
{ this.DialogResult = DialogResult.No; this.Close(); }
}
Comment puis-je passer le Uri pour obtenir le fichier qui a le caractère spécial dans son nom?
Cela a fonctionné lorsque j'ai changé le nom du fichier.