Dinakar Nethi

A .NET/SQL Server Blog

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

About Me

Links

Subscriptions

Article Categories



VB.NET

VB.NET
VB.NET code to check if a file exists

Function CheckIfFileExists(ByVal FolderPath, ByVal FileName) As Boolean

Dim objFSO

Dim objFolder, file

objFSO = CreateObject("Scripting.FileSystemObject")

objFolder = objFSO.GetFolder(FolderPath)

For Each file In objFolder.files

If LCase(file.name) = Trim(LCase(FileName)) Then

FileExists = True

Else

FileExists = False

End If

Next

objFSO = Nothing

Return FileExists

End Function

posted Friday, June 11, 2004 2:58 PM by dinakar with 1 Comments

VB.NET code to show a list of files in a directory

Private Sub ShowFiles(path as string)

Dim d() As String

d = System.IO.Directory.GetFiles(path)

Dim en As System.Collections.IEnumerator

en = d.GetEnumerator

While en.MoveNext

MsgBox(CStr(en.Current))

End While

End Sub

posted Friday, June 11, 2004 2:56 PM by dinakar with 0 Comments

VB.NET code to check if a folder exists

Function CheckFolderExists(ByVal sFolderName)

EventLog1.WriteEntry("inside checkfolder func - begin")

Dim FileSystemObject

FileSystemObject = CreateObject("Scripting.FileSystemObject")

If (FileSystemObject.FolderExists(sFolderName)) Then

CheckFolderExists = True

Else

CheckFolderExists = False

End If

FileSystemObject = Nothing

EventLog1.WriteEntry("file exists - " & CheckFolderExists)

EventLog1.WriteEntry("inside checkfolder func - end")

End Function

posted Friday, June 11, 2004 2:54 PM by dinakar with 0 Comments

VB.NET code to create a new folder

Function CreateNewFolder(ByVal Path, ByVal NewFolderName)

Dim objFSO

objFSO = CreateObject("Scripting.FileSystemObject")

Dim FullPath

FullPath = Path & NewFolderName

If Not objFSO.FolderExists(FullPath) Then

objFSO.CreateFolder(FullPath)

CreateNewFolder = True

Else

CreateNewFolder = False

End If

objFSO = Nothing

End Function

posted Friday, June 11, 2004 2:53 PM by dinakar with 1 Comments




Powered by Dot Net Junkies, by Telligent Systems