[Mono-dev] R: System.IO.Path: inconsistent paths from Windowsclients

Robert Jordan robertj at gmx.net
Mon Jun 26 12:26:37 EDT 2006


subscription.sapi wrote:
> Yes. We'are porting a WEB application from windows to linux+mono.
> 
> Yes, on linux the directory separator is "/", but if a Windows client is connected on web page on linux+mono+apache server, and a web page allow for file uploads: probably mono server should be platform independent or we should distinguish at "application level" between web Linux clients or web Microsoft clients.


BTW, you should *not* rely on PostedFile.FileName. It's rather
informative and it might even contain bogus data.

What happens to your app if, for example, a MacOS 9 browser is
sending colon separated file names? Under Windows the app
will throw an exception.

Robert

> 
>  
> 
>  
> 
> A test case listing is below (server side code on a web application):
> 
>  
> 
> string FileName=myFile.PostedFile.FileName;
> 
> Label1.Text= "dir sep: "+Path.DirectorySeparatorChar+"<br>";
> 
> Label1.Text+= "pat sep: "+Path.PathSeparator+"<br>";
> 
> // Prendo solo il nome del file senza il percorso.
> 
> Label1.Text+= "0"+myFile.PostedFile.FileName+"<br>";
> 
> Label1.Text+= "1"+Path.GetFileName(myFile.PostedFile.FileName)+"<br>";
> 
> Label1.Text+= "2"+Path.GetDirectoryName(myFile.PostedFile.FileName)+"<br>";
> 
> Label1.Text+= "3"+Path.GetFileNameWithoutExtension(myFile.PostedFile.FileName)+"<br>";
> 
> Label1.Text+= "4"+Path.GetPathRoot(myFile.PostedFile.FileName)+"<br>";
> 
>  
> 
>  
> 
> Roberto Cazzato
> 
> A.P.Systems srl
> 
> via Milano 89/91, ang. via Cimarosa
> 
> 20013 Magenta (MI)
> 
> Tel: +39 02 972261
> 
> Fax: +39 02 97226339
> 
> Mobile: +39 348 2200850
> 
> E-Mail: roberto.cazzato at apsystems.it
> 
> http://www.apsystems.it
> 
>  
> 
> -----Messaggio originale-----
> Da: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-bounces at lists.ximian.com] Per conto di Robert Jordan
> Inviato: lunedì 26 giugno 2006 17.42
> A: mono-devel-list at lists.ximian.com
> Oggetto: Re: [Mono-dev] System.IO.Path: inconsistent paths from Windowsclients
> 
>  
> 
> subscription.sapi wrote:
> 
>> I've different behavior in ms.net framework and mono framework when I
> 
>> use methods in "System.IO.Path" class.
> 
> 
>> Test Case Description:
> 
>  
> 
> Next time please post the source code of your test case
> 
> along with a system description (Mono version, OS, etc.).
> 
>  
> 
>> MONO:
> 
> 
>> Input path: D:\R&D\doc\jd\StandardJD.doc
> 
> 
>> Output path: 
> 
> 
>> Path.GetFileName
> 
>> D:\R&D\doc\jd\StandardJD.doc
> 
>> Path.GetDirectoryName                       
> 
>> Path.GetFileNameWithoutExtension      D:\R&D\doc\jd\StandardJD
> 
>> Path.GetPathRoot                               
> 
>  
> 
> I cannot reproduce this with Mono 1.1.15 under Windows,
> 
> so you're probably testing under Linux.
> 
>  
> 
> The directory separator under Linux is '/' or
> 
> Path.DirectorySeparatorChar, so you have to flip the '\'.
> 
>  
> 
> Robert
> 
>  
> 
> _______________________________________________
> 
> Mono-devel-list mailing list
> 
> Mono-devel-list at lists.ximian.com
> 
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list