Monday, August 15, 2011

Access problem while Copying & moving content of a file from one folder to another folder

Hi All,


This below code is to read the content of a file & moving that file from one folder to another folder
in vb.net.







Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ClickDim di As New IO.DirectoryInfo("D:\Test")Dim diar1 As IO.FileInfo() = di.GetFiles()Dim dra As IO.FileInfoDim fs As System.IO.FileStreamDim sr As StreamReaderDim line As String = ""
For Each dra In diar1'fs = New FileStream(di.ToString + "\" + dra.ToString, FileMode.Open, FileAccess.Read)fs =
sr =


New FileStream(di.ToString + "\" + dra.ToString, FileMode.Open, FileAccess.Read, FileShare.Read)New StreamReader(fs)Dim LineCount As Integer = 0While Not (sr.EndOfStream())'line = sr.ReadToEnd()line = sr.ReadLine()
LineCount += 1
End Whilefs.Close()
NextMoveProcessedFiles(
"D:\Test\", "D:\Test1", "Test.txt")End Sub
Sub MoveProcessedFiles(ByVal StrSourceFilePath As String, ByVal StrTargetDir As String, ByVal strFileName As String)Dim oldFile, newFile, TargetDir As StringTryoldFile = StrSourceFilePath + strFileName
TargetDir = StrTargetDir
newFile = TargetDir +
"\" + strFileNameIf Not File.Exists("D:\Test1\" + strFileName) Then
theFile.Close()
File.Delete(newFile)
File.Move(oldFile, newFile)
Dim theFile As FileStream = File.Create("D:\Test1\" + strFileName)End If

Catch ex As Exception'MsgBox(ex.Message)FinallyEnd Try


Access problem while Copying & moving content of a file from one folder to another folder is solved  if we use filestream to create a file .

End Sub

all integers are displayed in hex format during debugging in vb.net

Hi All,

This is an uncommon problem during debugging .
All integer values will be displayed in hex format.

Solution:

While debugging ,right click to get Quickwatch window & in that window right click
and unselect Hexadecimal display.