Delete files after upload

Dec 8, 2010 at 4:52 PM

i am uploading files to SharePoint site from a network share. after successfully uploading, i need to delete the original files. 

everything is working except i can't seem to delete the LAST file uploaded. Error = The process cannot access the file <file> because it is being used by another process.

Help is appreciated!

protected void FileReceived(object sender, FileReceivedEventArgs args)
        {                                          
            // Delete originals after last file           
            if (args.isLast)
            {                                                
                foreach (string filename in filenames)
                {  

                     System.IO.File.Delete(filename);                               

                 }          
            }           
        } 

Dec 21, 2010 at 4:31 PM

i figured out why this error occurs. the islast flag is set to true on the second to last file when more than two files are selected to upload. i have reported the issue in issue tracker.