473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating and populating folders in vb.net

9 New Member
I have a text file with "|" as a delimeter with three (3) fields

XXX-12345|\\YYYYYYY|\\ZZZZZZZZ

I need to read these files into an output folder. The problem that I'm having is that I need to create folders with the first part of the files (xxx-12345) and place the files \\YYYYYYY AND \\ZZZZZZZZ in this folder. Here is the code that I have so far..

Imports System.IO

Public Class frmRedaction_Copier
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Friend WithEvents btnProcess As System.Windows.Forms.Button
Friend WithEvents btnFileFind As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents lblSaveFolder As System.Windows.Forms.Label
Friend WithEvents btnOutDir As System.Windows.Forms.Button
Friend WithEvents chkEID As System.Windows.Forms.CheckBox
Friend WithEvents txtFileName_In As System.Windows.Forms.TextBox
Friend WithEvents txtFileName_Out As System.Windows.Forms.TextBox
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
Friend WithEvents txtData As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.btnProcess = New System.Windows.Forms.Button
Me.txtFileName_In = New System.Windows.Forms.TextBox
Me.btnFileFind = New System.Windows.Forms.Button
Me.btnExit = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.lblSaveFolder = New System.Windows.Forms.Label
Me.txtFileName_Out = New System.Windows.Forms.TextBox
Me.btnOutDir = New System.Windows.Forms.Button
Me.chkEID = New System.Windows.Forms.CheckBox
Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
Me.txtData = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'btnProcess
'
Me.btnProcess.Location = New System.Drawing.Point(232, 152)
Me.btnProcess.Name = "btnProcess"
Me.btnProcess.TabIndex = 4
Me.btnProcess.Text = "Process"
'
'txtFileName_In
'
Me.txtFileName_In.Location = New System.Drawing.Point(128, 32)
Me.txtFileName_In.Name = "txtFileName_In"
Me.txtFileName_In.Size = New System.Drawing.Size(384, 20)
Me.txtFileName_In.TabIndex = 0
Me.txtFileName_In.Text = ""
'
'btnFileFind
'
Me.btnFileFind.Location = New System.Drawing.Point(528, 32)
Me.btnFileFind.Name = "btnFileFind"
Me.btnFileFind.Size = New System.Drawing.Size(24, 20)
Me.btnFileFind.TabIndex = 1
Me.btnFileFind.Text = "..."
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(376, 152)
Me.btnExit.Name = "btnExit"
Me.btnExit.TabIndex = 5
Me.btnExit.Text = "E&xit"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 24)
Me.Label1.TabIndex = 8
Me.Label1.Text = "Load File"
'
'lblSaveFolder
'
Me.lblSaveFolder.Location = New System.Drawing.Point(24, 88)
Me.lblSaveFolder.Name = "lblSaveFolder"
Me.lblSaveFolder.Size = New System.Drawing.Size(88, 24)
Me.lblSaveFolder.TabIndex = 9
Me.lblSaveFolder.Text = "Output Folder"
'
'txtFileName_Out
'
Me.txtFileName_Out.Location = New System.Drawing.Point(128, 88)
Me.txtFileName_Out.Name = "txtFileName_Out"
Me.txtFileName_Out.Size = New System.Drawing.Size(384, 20)
Me.txtFileName_Out.TabIndex = 2
Me.txtFileName_Out.Text = ""
'
'btnOutDir
'
Me.btnOutDir.Location = New System.Drawing.Point(528, 88)
Me.btnOutDir.Name = "btnOutDir"
Me.btnOutDir.Size = New System.Drawing.Size(24, 20)
Me.btnOutDir.TabIndex = 3
Me.btnOutDir.Text = "..."
'
'chkEID
'
Me.chkEID.Location = New System.Drawing.Point(32, 136)
Me.chkEID.Name = "chkEID"
Me.chkEID.Size = New System.Drawing.Size(104, 16)
Me.chkEID.TabIndex = 12
Me.chkEID.Text = "Rename as EID"
Me.chkEID.Visible = False
'
'txtData
'
Me.txtData.Location = New System.Drawing.Point(32, 208)
Me.txtData.Multiline = True
Me.txtData.Name = "txtData"
Me.txtData.ReadOnly = True
Me.txtData.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.txtData.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtData.Size = New System.Drawing.Size(592, 128)
Me.txtData.TabIndex = 14
Me.txtData.TabStop = False
Me.txtData.Text = ""
Me.txtData.WordWrap = False
'
'frmRedaction_Copier
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.ClientSize = New System.Drawing.Size(664, 358)
Me.Controls.Add(Me.txtData)
Me.Controls.Add(Me.chkEID)
Me.Controls.Add(Me.btnOutDir)
Me.Controls.Add(Me.txtFileName_Out)
Me.Controls.Add(Me.lblSaveFolder)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnFileFind)
Me.Controls.Add(Me.txtFileName_In)
Me.Controls.Add(Me.btnProcess)
Me.Name = "frmRedaction_Copier"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = "Redaction Copier"
Me.ResumeLayout(False)

End Sub

#End Region



Private Sub btnFileFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFileFind.Click

Dim stFileName_In As String
Dim openFileDialog1 As New OpenFileDialog

openFileDialog1.InitialDirectory = System.Environment.CurrentDirectory
openFileDialog1.Title = "Open Text File"
openFileDialog1.Filter = "Text files (*.txt)|*.txt"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = DialogResult.OK Then
Dim stFilePathAndName_In As String = openFileDialog1.FileName
Dim MyFile As FileInfo = New FileInfo(stFilePathAndName_In)
stFileName_In = MyFile.Name
Me.txtFileName_In.Text = stFilePathAndName_In
End If


End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub


Private Sub btnOutDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutDir.Click

Dim stFileName_Out As String

SaveFileDialog1.InitialDirectory = System.Environment.CurrentDirectory
SaveFileDialog1.Title = "Save as"
SaveFileDialog1.Filter = "Text files (*.txt)|*.txt"
SaveFileDialog1.FilterIndex = 1
SaveFileDialog1.RestoreDirectory = True

If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim stFilePathAndName_Out As String = SaveFileDialog1.FileName
Dim MyFile_Out As FileInfo = New FileInfo(stFilePathAndName_Out)
stFileName_Out = MyFile_Out.Name
Me.txtFileName_Out.Text = stFilePathAndName_Out
End If

End Sub

Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
Try

If Me.txtFileName_In.Text = "" Then
MessageBox.Show("Please enter the file name to be processed")
Me.btnFileFind.Focus()
'End If

'If Me.txtFileName_Out.Text = "" Then
'MessageBox.Show("Please enter the output destination")
'Me.btnOutDir.Focus()

Else
Dim fileToRead As String
fileToRead = Me.txtFileName_In.Text

Dim filestream As StreamReader
filestream = File.OpenText(fileToRead)

Dim readcontents As String
readcontents = filestream.ReadToEnd()

Dim textdelimiter As String
textdelimiter = "|"

Dim splitter = Split(readcontents, textdelimiter)

Dim i As Integer

For i = 0 To UBound(splitter)
Me.txtData.Text &= "" & i + 1 & " " & splitter(i) & vbCrLf
Next i

End If


Catch ex As Exception

End Try

End Sub

End Class

How do I acomplish this?
Aug 13 '07 #1
0 1319

Sign in to post your reply or Sign up for a free account.

Similar topics

13
7168
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
2
6062
by: Karuppasamy | last post by:
Hi I want to populate all the files and folders of System in a Treeview control like Windows Explorer. I try this using File System Objects. But sometimes I am getting an error like 'Access...
3
1981
by: dave | last post by:
I am using vs.net 2003 on windows xp. After clicking on a project within my solution and selecting create new folder vs.net responds back with , the "directory already exists". If i look at the...
1
1656
by: Richard Johansson | last post by:
Hi, I want to create an option for creating shortcuts to my application on the users desktop and Start menu in the setup. In my deployment project i have created the necessary checkboxes, and...
1
2602
by: Vagabond Software | last post by:
I am recursing through ALL folders and sub-folders below a certain level to list all the files of a certain type in those folders. I use two ArrayLists, alFiles and alFolders, to track matching...
5
2264
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
7
4078
by: Zeb | last post by:
Hi all I've developed a shopping cart in C# and to allow moderators to upload product images, news images and downloadable PDFs, the app creates a folder for each product. I start out with the...
0
2092
by: =?Utf-8?B?TGlhbSBNYWM=?= | last post by:
Hi Folks, I have embeded WMI scripting within a Visual Basic application to create remote shares and set permissions, I'm now moving to vb.net environment and having trouble getting my scripting...
1
1290
by: Mick Walker | last post by:
Hi all, I am wondering is it possible to create a physical Directory such as "C:\Test" using the DirectoryServices namespace. If so, does anyone have any resources on how to do it? I should...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.