Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi...I am having a problem with accessing the file. Here's the code that I am trying to execute.

==========================================

Dim proStat As New FileInfo("temp.tmp")

If proStat.Exists Then

Return True

Else

proStat.Create()

Return False

End If

==========================================

 

Later in the program, I am trying to delete this file in this way.

 

==========================================

Dim flinfo As New FileInfo("temp.tmp")

flinfo.Delete()

==========================================

At this point, it is giving me an error that the file is already being used by another process. i am not using this file anywhere in the program except these two. And, I guess we have no explicit way to "close" the file in the first instance since the FileInfo class has no such method.

 

What do you think is the problem here?

 

Thanks

SJ

Posted

Never mind..I was able to figure out whats wrong...I just changed the way I am creating the file.

 

==========================================

Dim proStat As New FileInfo("temp.tmp")

If proStat.Exists Then

Return True

Else

proStat.Create().Close()

Return False

End If

==========================================

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...