How to delete a file that is used
-
hey, When I'm trying to delete one of my created files. My program saids it is in use (by himself) but that's because the program is to fast. When I let him wait 10sec the lock is gone... But that not zo good if you have to delete 20-50 files. How can I unlock them automatically? Thx!!!
-
hey, When I'm trying to delete one of my created files. My program saids it is in use (by himself) but that's because the program is to fast. When I let him wait 10sec the lock is gone... But that not zo good if you have to delete 20-50 files. How can I unlock them automatically? Thx!!!
How are the files created? Did you maybe forgot to call close on some streams?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
How are the files created? Did you maybe forgot to call close on some streams?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
There are all created with: new DirectoryInfo(Path.GetDirectoryName(path)).Create(); StreamWriter writer = new StreamWriter(path); writer.WriteLine(content); writer.Close(); But than the locks are fine. But after all the files are created I zip them with "SharpZipLib" and is places locks that last realy long... thx
-
There are all created with: new DirectoryInfo(Path.GetDirectoryName(path)).Create(); StreamWriter writer = new StreamWriter(path); writer.WriteLine(content); writer.Close(); But than the locks are fine. But after all the files are created I zip them with "SharpZipLib" and is places locks that last realy long... thx
Then there's a bug in the zip library, or in how you're using it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Then there's a bug in the zip library, or in how you're using it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I don't think so everything is closed: using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Diagnostics; using System.Threading; using log4net; using ICSharpCode.SharpZipLib.Zip; using System.Collections; using System.Collections.Specialized; namespace InterfaceCollector.domain.DAL { class Zip { private string destination; private readonly ILog log = LogManager.GetLogger(typeof(Zip)); static Hashtable excludeDirs = new Hashtable(); static string startFolder = String.Empty; static string outputZipPath = String.Empty; static string password = String.Empty; public Zip() {} static private Zip instance = null; static public Zip Instance { get { if (instance == null) instance = new Zip(); return instance; } } public void ZipIt(string Path,string password) { log4net.LogManager.Shutdown(); try { ArrayList ar = GenerateFileList(Path); // generate file list // find number of chars to remove from orginal file path int TrimLength = (Directory.GetParent(Path)).ToString().Length; TrimLength += 1; //remove '\' FileStream ostream = null; byte[] obuffer; ZipOutputStream oZipStream = new ZipOutputStream(System.IO.File.Create(Destination)); // create zip stream if (password != String.Empty) oZipStream.Password = password; oZipStream.SetLevel(9); // 9 = maximum compression level ZipEntry oZipEntry; DateTime timeStap = DateTime.Now; string output = ""; int lenghtWrittenString = 0; double percent = 1; int countFiles = 0; foreach (string Fil in ar) // for each file, generate a zipentry { countFiles++; percent = countFiles * 100 / ar.Count; //Display % on progressScreen if (timeStap <= DateTime.Now) { timeStap = DateTime.Now.AddMilliseconds(1000); ApplicationDirector.Instance.removeCharachtersFromProgressScreen(lenghtWrittenString); if (percent < 10
-
Then there's a bug in the zip library, or in how you're using it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
That means, something is NOT closed, but it is eventually garbage collected.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
That means, something is NOT closed, but it is eventually garbage collected.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
That's a hack. You should instead figure out what's going wrong with the zip library.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
That's a hack. You should instead figure out what's going wrong with the zip library.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Well, I'd think if it's a problem in the framework, then others will have encountered it. If you find nothing on google, it's a bug in your code. 'If we have time at the end', means, we're going to leave it broken. At least, that's what I'd expect it to mean.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
hey, When I'm trying to delete one of my created files. My program saids it is in use (by himself) but that's because the program is to fast. When I let him wait 10sec the lock is gone... But that not zo good if you have to delete 20-50 files. How can I unlock them automatically? Thx!!!
In the TaskManager Extension application, there is a way to force close handle. If we can have that done, the problem is solved. TaskManager Extension at: http://www.codeproject.com/system/Task_Manager_Extension.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
In the TaskManager Extension application, there is a way to force close handle. If we can have that done, the problem is solved. TaskManager Extension at: http://www.codeproject.com/system/Task_Manager_Extension.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips