File.Move then Delete not supported by Compact Framework 2.0?

The following code crashes on the second Delete call.

        using (var str = new StreamWriter(newFileName))
        {
            foreach (Entry entry in this.Entries)
            {
                str.WriteLine(
                    String.Format(
                        @"""{0}"";{1:yyyy-dd-MMThh:mm:ss};""none"""
                        , entry.Data
                        , entry.Date
                    )
                );
            }
        }

            File.Delete(delFileName);
            File.Move(curFileName, delFileName);
            File.Move(newFileName, curFileName);
            File.Delete(delFileName); // Crash

"The process can not access the file '\\asld.csv' because it is being used by another process."

So it's just like File.Move(curFileName, delFileName) causes a lock (or something) on the file and doesn't release it afterward.

Note: I'm working with a Smart Device emulated by Visual Studio 2008.

Answers


I fixed it.

The problem cause was actually in a different method that was called at some point in time before the method the exception occurred.

I had a "load" method where I forgot the using clause.

    private void load()
    {
        this.lstEntries = new List<Entry>();

        var delFileName = String.Format(@"{1}\{0}d.csv", this.FilePrefix, this.Folder);
        var curFileName = String.Format(@"{1}\{0}c.csv", this.FilePrefix, this.Folder);

        if (File.Exists(delFileName) && !File.Exists(curFileName))
        {
            curFileName = delFileName;
        }

        if (File.Exists(curFileName))
        {
            using (var str = new StreamReader(curFileName)) // fixed with using

Need Your Help

unable to build nw.js with diskdb

angularjs node.js require nw.js

I am developing a sample desktop application using node webkit and angular js referring this tutorial series. I had used the diskdb for storing the data and will be connected as,

Jquery animation swipe

jquery css

I need to make may brand-image animated so when site open it shuld swipe or go linear from left side to right side and then back on his position. I googled it but i dont know how to make this funci...