[Mono-bugs] [Bug 81005][Nor] New - WebClient.DownloadFile() tries to explicitly create the target file/fails for existing files

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Mar 2 10:43:31 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 benjamin.podszun at gmail.com.

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

--- shadow/81005	2007-03-02 10:43:31.000000000 -0500
+++ shadow/81005.tmp.13742	2007-03-02 10:43:31.000000000 -0500
@@ -0,0 +1,74 @@
+Bug#: 81005
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: benjamin.podszun at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: WebClient.DownloadFile() tries to explicitly create the target file/fails for existing files
+
+Description of Problem:
+
+See the summary (WebClient.DownloadFile() tries to explicitly create the
+target file/fails for existing files): Microsoft's behaviour and the Mono
+documentation both agree that DownloadFile() should overwrite the file if
+it already exists. This doesn't work.
+
+Steps to reproduce the problem:
+
+Compile the following snippet/testcase:
+
+using System;
+using System.IO;
+using System.Net;
+
+public class WebClientTest {
+  public static void Main(string[] args) {
+    WebClient wc = new WebClient();
+    string filename = Path.GetTempFileName();
+    wc.DownloadFile("http://google.com/", filename);
+    Console.WriteLine("Downloaded the file to {0}", filename);
+  }
+}
+
+Actual Results:
+
+Unhandled Exception: System.IO.IOException: Could not create file
+"C:\DOCUME~1\BENJAM~1.POD\LOCALS~1\Temp\tmp3ee1a300.tmp". File already exists.
+  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:
+
+Something like:
+
+C:\Temp>WebClientTest.exe
+Downloaded the file to C:\DOCUME~1\BENJAM~1.POD\LOCALS~1\Temp\tmp65.tmp
+How often does this happen? 
+
+
+Additional Information:
+
+Should be quite easy to fix this one?


More information about the mono-bugs mailing list