Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Cannot delete file using FileSystemUtils.DeleteFile()Cannot delete file using FileSystemUtils.DeleteFile()
Previous
 
Next
New Post
6/24/2008 11:35 AM
 

Hello,

i am trying to delete files which are located inside a folder.

I use FileSystemUtils.GetFilesByFolder() to get the files of the given folder and then i attempt to delete the file using FileSystemUtils.DeleteFile().

Most of the times, it does not allow the deletion and get the following error message:

"The process cannot access the file '....' because it is being used by another process."

Does the FileSystemUtils.GetFilesByFolder() somehow lock that folder or files?

 

I appreciate any comment you can make on this.

Thanks,

M. Mourouti

 
New Post
6/26/2008 4:02 AM
 

Hello again,

i think it's not the methods i am using that are causing the problem.

I think it's the Bitmap object which is not releasing the resources quick enough.

Thanks,

M. Mourouti

 
New Post
6/30/2008 4:43 AM
 

Hello everyone,

after spending a lot of time on this, i concluded to my initial thoughts, that is, FileSystemUtils.GetFolder() locks the files in that folder and i cannot delete them after accessing them though that method. I have verified this in many ways, stepped through the code and as soon as i get the files using that method, they are locked.

Is that a known issue? Is there a workaround for this?

I thought that FileSystemUtils.GetFolder() would just work as simple as :

' Get folder.
Dim folder As System.IO.DirectoryInfo = ...

' Get files for that folder.
Dim Files() As System.IO.FileInfo = folder.GetFiles()

The above code works fine without locking the files .. but it would be great if i could user DotNetNuke FolderInfo and FileInfo objects instead.

I appreciate any comments you can make on this.

Thanks,

M. Mourouti

 
New Post
5/12/2009 8:56 AM
 

Hi,

Did you ever manage to resolve this?, I'm having the same problem.

 

Update: example code of what I got to work.

---------------------------------------------------

            Dim folderInfo As DotNetNuke.Services.FileSystem.FolderInfo
            Dim fileInfo As DotNetNuke.Services.FileSystem.FileInfo
            Dim aryList2 As ArrayList

            Dim objFolderController As New DotNetNuke.Services.FileSystem.FolderController

            folderInfo = objFolderController.GetFolder(PortalId, imgFolderPath, True)
            If Not folderInfo Is Nothing Then
                aryList2 = FileSystemUtils.GetFilesByFolder(PortalSettings.PortalId, folderInfo.FolderID)
                For Each fileInfo In aryList2

                          'do you r stuff here
                Next
            End If

            folderInfo = Nothing

            fileInfo = Nothing  
            aryList2 = Nothing
 

            'GC.Collect()  - Doing this if you use FileSystemUtils.GetFolder also seems to work, but a bit to drastic!

---------------------------------------------------------------------------------

If anyone has any better ideas please post them.


 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Cannot delete file using FileSystemUtils.DeleteFile()Cannot delete file using FileSystemUtils.DeleteFile()


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out