c# - WebClient DownloadFile is in use by another process -


I am getting an error that my file is in use by another process, I believe this is because It is not complete downloading before entering the experiment statement?

Below is my code, I have tried to invoke my download in Async and one downloadcompleted but it still produces the same problem. To ensure that the file was released to release the file was recommended, but it also does not help any help would be greatly appreciated.

  if (file.path.Contains (".zip")) {WebClient downloader = new WebClient (); Console WrightLine ("http://directory.com/api/download" + file.path); String download link = "http://directory.com/api/download" + file.path; Downloader Download file (new url (download link), "temporary."); Downloader.Dispose (); (Using LdifEntryReader LDIF = new LdifEntryReader (New LdifReader ("temp.ldif")) {for (login entry = ldif.ReadEntry (); entry = null;; entry = ldif.ReadEntry ()) Console.WriteLine ("Found: {0}", entry. Distilled nem); }}  

Update: Tried to do more under some recommendations:

 using  (WebClient Downloader = New WebClient ()) {console. WriteLine ("http://directory.com/api/download" + file.path); String download link = "http://directory.com/api/download" + file.path; Downloader.Download File (new URI (download link), @ "template.lif"); } Use (LdifEntryReader LDIF = New LdifEntryReader (New LdIFReader ("temp.ldif")) for {login entry = ldif.ReadEntry ();; entry = null; entry = ldif.ReadEntry ()) Console.WriteLine ("Found: {0}", entry. Distilled nem); }  


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -