Hi

I am running the below mention code in vb.net but problem is
when dir.txt already in c: drive it will read the text file
but if i delete the dir.txt file and create new one and in next line
try to read the same dir.txt file it will flash error "Could not find file c:\dir.txt"

Pls guide me .. why this type of problem accured..


thanks


asm


VB Code:
  1. Imports System
  2. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.         Dim SFile As System.IO.File
  4.         Dim VolRead As System.IO.StreamReader
  5.         Dim ReadTxt As String
  6.         Try
  7.             If SFile.Exists("C:\DIR.TXT") Then
  8.                 System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Del C:\DIR.TXT")
  9.             End If
  10.             System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Dir C:  > C:\DIR.TXT")
  11.             VolRead = New System.IO.StreamReader("C:\DIR.TXT")
  12.             ReadTxt = VolRead.ReadToEnd()
  13.             Label1.Text = "READING TEXT FILE OK.."
  14.             VolRead.Close()
  15.             If SFile.Exists("C:\Dir.txt") Then
  16.                 System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Del C:\DIR.TXT")
  17.             End If
  18.         Catch ex As Exception
  19.             Label1.Text = ex.Message
  20.         End Try
  21.     End Sub