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:
Imports System Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SFile As System.IO.File Dim VolRead As System.IO.StreamReader Dim ReadTxt As String Try If SFile.Exists("C:\DIR.TXT") Then System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Del C:\DIR.TXT") End If System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Dir C: > C:\DIR.TXT") VolRead = New System.IO.StreamReader("C:\DIR.TXT") ReadTxt = VolRead.ReadToEnd() Label1.Text = "READING TEXT FILE OK.." VolRead.Close() If SFile.Exists("C:\Dir.txt") Then System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Del C:\DIR.TXT") End If Catch ex As Exception Label1.Text = ex.Message End Try End Sub




Reply With Quote