2017-09-05 2 views
0

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.

Répondre

0

Pour une adresse de fichier qui contient des caractères spéciaux, vous souhaitez télécharger le fichier dépend du déploiement de l'accès spécial au support du serveur. Par exemple, si le serveur IIS ne supporte pas l'accès avec un caractère spécial, quels changements avez-vous fait avec url, le résultat est impossible.

Ce qui suit est une solution sur la manipulation du nom de fichier contient des caractères spéciaux, vous pouvez prendre référence avec lui.

https://helpx.adobe.com/experience-manager/kb/CannotOpenAFileHavingSpecialCharactersInTheFilenameOnIIS.html