|
-
Mar 26th, 2007, 11:51 PM
#1
Thread Starter
Lively Member
[2005] [error in file close]
hi friends,
In first line i gave the code like this
File.Create(txtbox1.text+".txt");
next line i gave
file.delete(txtbox1.text+".txt");
but it shows the error
" file is used by another process"
how to close the file
Last edited by manju.cdtech; Mar 27th, 2007 at 12:34 AM.
-
Mar 27th, 2007, 12:01 AM
#2
Re: [2005] [error in file close]
File.Create returns a FileStream object. You need to call the Close method of that object. If you don't assign the return value of File.Create to a variable then you have no access to that FileStream object so you have no way of closing the file. Always read the documentation for the types and members that you're using. The doco for the File.Create has a code example of just that so you wouldn't have had to ask.
-
Mar 27th, 2007, 12:23 AM
#3
Re: [2005] [error in file close]
vb Code:
Try
Dim fileStream As FileStream
fileStream = System.IO.File.Create("E:\Text1.txt")
fileStream.Close()
'For Deleting
System.IO.File.Delete("E:\Text1.txt")
Catch ex As Exception
End Try
-
Mar 27th, 2007, 12:29 AM
#4
Thread Starter
Lively Member
Re: [2005] [error in file close]
-
Mar 27th, 2007, 12:31 AM
#5
Re: [2005] [error in file close]
 Originally Posted by manju.cdtech
Thanks for your help ...
Your welcome
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|