[Mono-bugs] [Bug 81066][Wis] New - [PATCH] WebClient.DownloadFile() fails if the target file does not exist

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Mar 7 08:40:08 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by frederik.carlier at ugent.be.

http://bugzilla.ximian.com/show_bug.cgi?id=81066

--- shadow/81066	2007-03-07 08:40:08.000000000 -0500
+++ shadow/81066.tmp.29585	2007-03-07 08:40:08.000000000 -0500
@@ -0,0 +1,72 @@
+Bug#: 81066
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: frederik.carlier at ugent.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] WebClient.DownloadFile() fails if the target file does not exist
+
+Description of Problem:
+The fix for bug 81005 causes a regression. If the target file does not
+exist, the method will fail.
+
+The regression is caused by the fact that FileMode.CreateNew |
+FileMode.Truncate is passed to the FileStream constructor, however,
+FileMode.Create should have been passed.
+(FileMode.Create != FileMode.CreateNew | FileMode.Truncate);
+
+Reference:
+http://svn.myrealbox.com/viewcvs/trunk/mcs/class/corlib/System.IO/FileMode.cs?rev=46462&view=auto
+http://svn.myrealbox.com/viewcvs/trunk/mcs/class/System/System.Net/WebClient.cs?rev=73635&r1=65451&r2=73635
+
+Attached is sample code that demonstrates the problem, it includes a
+testcase for both this bug and bug 81005.
+
+Steps to reproduce the problem:
+1. gmcs bug.cs
+2. mono bug.exe
+
+Actual Results:
+fcarlier at col-clt-04:~$ mono 81005.exe 
+Downloaded the file to /tmp/tmp9e8a933.tmp
+
+Unhandled Exception: System.IO.FileNotFoundException: Could not find file
+"/tmp/tmp9e8a933.tmp"
+File name: '/tmp/tmp9e8a933.tmp'
+  at System.IO.FileStream..ctor (System.String name, FileMode mode,
+FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous,
+FileOptions options) [0x00000] 
+  at System.IO.FileStream..ctor (System.String name, FileMode mode) [0x00000] 
+  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor
+(string,System.IO.FileMode)
+  at System.Net.WebClient.DownloadFileCore (System.Uri address,
+System.String fileName) [0x00000] 
+  at System.Net.WebClient.DownloadFile (System.Uri address, System.String
+fileName) [0x00000] 
+  at System.Net.WebClient.DownloadFile (System.String address,
+System.String fileName) [0x00000] 
+  at (wrapper remoting-invoke-with-check) System.Net.WebClient:DownloadFile
+(string,string)
+  at WebClientTest.Main (System.String[] args) [0x00000] 
+
+Expected Results:
+fcarlier at col-clt-04:~$ mono 81005.exe 
+Downloaded the file to /tmp/tmp7d2bc4bc.tmp
+Downloaded the file to /tmp/tmp7d2bc4bc.tmp
+
+
+How often does this happen? 
+Always
+
+Additional Information:
+None


More information about the mono-bugs mailing list