Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   How can i delete Temp using fileStream in Vb.net (http://www.go4expert.com/forums/i-delete-temp-using-filestream-vbnet-t10706/)

mj_yusuf 22May2008 07:25

How can i delete Temp using fileStream in Vb.net
 
Hi

I try to delete system Temp file using this following method.

Public Sub DeleteTempFile()
Dim sTempFileName As String
For Each sTempFileName In Directory.GetFiles(GetTempDirectory())
System.IO.File.Delete(sTempFileName)
End Sub

Function GetTempDirectory() As String
Return Environment.GetEnvironmentVariable("TEMP")
End Function


But when i delete i get "IOException wad unhandled" error.

That error messge is: "The process cannot access the file 'C:\Documents and Settings\Administrator\Local Settings\Temp\29.tmp' because it is being used by another process."




Can anybody help me solution to solve this problem.
by
Yusuf

shabbir 22May2008 08:18

Re: How can i delete Temp using fileStream in Vb.net
 
In the temp folder you have some files which cannot be deleted which you are trying to delete it.

shabbir 23May2008 08:40

Re: How can i delete Temp using fileStream in Vb.net
 
Moved to Visual Basic forum for better responses.

mj_yusuf 6Jun2008 15:19

How can validate cell in datagridview Vb.net
 
Hi ,
Am using this following code my cell validating,This code if user leave empty row or if row got focus at empty cell it will prompt messagebox until user enter value.


but i need if user want to continue with empty value it allow to add new row or go to other tab.

Please help me...

TIA.

By
Yusuf.

Private Sub dgvHeaderRemarks_CellValidating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEve ntArgs) Handles dgvHeaderRemarks.CellValidating

If dgvHeaderRemarks.Columns(e.ColumnIndex).Name = "Remarks" Then
If e.FormattedValue IsNot Nothing AndAlso _
String.IsNullOrEmpty(e.FormattedValue.ToString().T rim) Then

'dgvSupportingDocument.CurrentRow.Cells(1).Selecte d = True

MessageBox.Show("HeaderRemarks Field cannot be empty.Please use delete row.", "HeaderRemarks", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

dgvHeaderRemarks.CancelEdit()
e.Cancel = True
End If
End If
End Sub

mj_yusuf 16Jun2008 10:41

Re: How can i delete Temp using fileStream in Vb.net
 
Quote:

Originally Posted by shabbir
In the temp folder you have some files which cannot be deleted which you are trying to delete it.

Hi Sabir
I got a solution for that temp file deletion.

Thanks for ur reply.

mj_yusuf 16Jun2008 10:46

Re: How can i delete Temp using fileStream in Vb.net
 
Hi Sabir,

I have one more doubt in datagridview cell validating.I need to validate empty row.If user leave empty row i need to prompt messge to delete or enter value.

I am using this following code for my cell validation.But,is not set for my project.

Please help me.

Code is:
If dgvHeaderRemarks.Columns(e.ColumnIndex).Name = "Remarks" Then

'If e.FormattedValue IsNot Nothing Or _
If String.IsNullOrEmpty(e.FormattedValue.ToString().T rim) Then
MessageBox.Show("HeaderRemarks Field cannot be empty.Please use delete row.", "HeaderRemarks", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

dgvHeaderRemarks.CancelEdit()
e.Cancel = True
End If
End If

How can solve this problem.

TIA


All times are GMT +5.5. The time now is 15:09.