Accessing file twisely using asp.net using VB.Net

Hello Friends,

I am new on this group.

I have a problem in my functionality.

i am using asp.net using vb.net.

The pocess is as  a way that I have to send a mail with attachment.I am using Input file type tag control to get Attachment file from directory.After it i am saving attachment file on server folder.After it i am sending file path to attachment function as string.After it attachment is working fine.

But after it i want to delete that file from server and when i wrote code  for delete fileas following:

File.delete(Path of file)

but when runtime start execute this code ther is error as fllowing:

"The process can not access the file <Path of file> because it is being used by another process.mscorlib"

 

Please help me.

 

Arminder Singh

0
Arminder
7/11/2006 2:41:53 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

4 Replies
1105 Views

Similar Articles

[PageSpeed] 1

Make sure in your code you close the access to the file before you try to delete it.
Welcome to my SQL/ASPNET forum for Chinese
http://51up.org/bbs/forumdisplay.php?fid=38
0
Iori_Jay
7/12/2006 2:45:58 AM

 

Thanks lori for your help .

I know i need to close the  access but i don't know how to close that access.

In first access of file i am using function to send mail and i am giving only path to the functin as a string parameter.Like following

Mailing.RelayMail(strSenderName, strSenderAddress, strRecipientName, strRecipientAddress, strSubject, txtBody, attachment)

attachment=Physical path of file.

After  it i am deleting file by using following code.

File.Delete(Physical Path of file as a parameter)

and i dn't know how to close tha access after send attachment .

 

waiting for ur reply........

Arminder

1
Arminder
7/12/2006 5:57:21 AM


O lori ....

Thanks for ur comments....

I have resolved the problem with the help of ur comments.....

I ispose all the objects which i was using  or process and prblem is resolved.

 

Again Thanks to u for help for ur so valuable comment....

 

Arminder

0
Arminder
7/12/2006 8:26:59 AM
Hi Arminder is not online. Last active: 07-12-2006, 5:36 AM Arminder , it's great that you've self-resolved the issueSmile
Welcome to my SQL/ASPNET forum for Chinese
http://51up.org/bbs/forumdisplay.php?fid=38
0
Iori_Jay
7/12/2006 9:53:17 AM
Reply: