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
Printable View
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
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.
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
Thanks for your help ...
Your welcome:thumb:Quote:
Originally Posted by manju.cdtech