473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Create Directory with VS2008

Greetings
New to Visual Studio 2008.
Always us VB6.0 SP5.

I am trying to copy files from A to B.
I select a directory, and copy files. Works ok, but it does not create the
directory first.

snippet.
Private Sub cmdTo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDialog1

..ShowNewFolderButton = True

..Description = "Select the Location for Files to be copied to."

..RootFolder = Environment.SpecialFolder.Desktop

End With

' If a file is not opened, then set the initial directory to the

' FolderBrowserDialog.SelectedPath value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDialog1.ShowDialog()

' OK button was pressed.

If (result = DialogResult.OK) Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

' Cancel button was pressed.

ElseIf (result = DialogResult.Cancel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCopy.Click

''''My.Computer.FileSystem.CreateDirectory(lblTo.T ext & "\" &
lblFrom.Text)"""" Does not work

My.Computer.FileSystem.CopyDirectory(lblFrom.Text, lblTo.Text, _

FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)

Exit Sub

I have added this line

My.Computer.FileSystem.CreateDirectory(lblTo.Text & "\" & lblFrom.Text)

Does not except this. In VB6 I could create a directory with from "\" to.

How do you create a directory, when selection is made.
--
Thanks in advance
bob
ro******@mountaincable.net
Jan 5 '08 #1
4 2799
Robert,

I first will try you to learn how to fish and then give you the fish.

If you test this like you do and it does not work, then simplify your
problem, in this case by instead using a string instead of a variable you
see direct the problem.

My.Computer.FileSystem.CreateDirectory("C:\Robert" )

I tried this and it created a folder on Drive C Robert.

As I already expected (but I seldom use the My Class) does it show direct
the problem for you.

Cor



"Robert" <ro****@nowhere.comschreef in bericht
news:en**************@TK2MSFTNGP02.phx.gbl...
Greetings
New to Visual Studio 2008.
Always us VB6.0 SP5.

I am trying to copy files from A to B.
I select a directory, and copy files. Works ok, but it does not create
the directory first.

snippet.
Private Sub cmdTo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDialog1

.ShowNewFolderButton = True

.Description = "Select the Location for Files to be copied to."

.RootFolder = Environment.SpecialFolder.Desktop

End With

' If a file is not opened, then set the initial directory to the

' FolderBrowserDialog.SelectedPath value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDialog1.ShowDialog()

' OK button was pressed.

If (result = DialogResult.OK) Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

' Cancel button was pressed.

ElseIf (result = DialogResult.Cancel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCopy.Click

''''My.Computer.FileSystem.CreateDirectory(lblTo.T ext & "\" &
lblFrom.Text)"""" Does not work

My.Computer.FileSystem.CopyDirectory(lblFrom.Text, lblTo.Text, _

FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)

Exit Sub

I have added this line

My.Computer.FileSystem.CreateDirectory(lblTo.Text & "\" & lblFrom.Text)

Does not except this. In VB6 I could create a directory with from "\" to.

How do you create a directory, when selection is made.
--
Thanks in advance
bob
ro******@mountaincable.net
Jan 6 '08 #2

"Robert" <ro****@nowhere.comha scritto nel messaggio Greetings
New to Visual Studio 2008.
Always us VB6.0 SP5.
I am trying to copy files from A to B.
I select a directory, and copy files. Works ok, but it does not create
the directory first.
snippet.
Private Sub cmdTo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTo.Click
'Open the Dialog Box to Copy Files.
With FolderBrowserDialog1
.ShowNewFolderButton = True
.Description = "Select the Location for Files to be copied to."
.RootFolder = Environment.SpecialFolder.Desktop
End With
' If a file is not opened, then set the initial directory to the
' FolderBrowserDialog.SelectedPath value.
If lblTo.Text = "" Then
lblTo.Text = FolderBrowserDialog1.SelectedPath
lblTo.Text = Nothing
End If
' Display the openFile dialog.
Dim result As DialogResult = FolderBrowserDialog1.ShowDialog()
' OK button was pressed.
If (result = DialogResult.OK) Then
lblTo.Text = FolderBrowserDialog1.SelectedPath
' Cancel button was pressed.
ElseIf (result = DialogResult.Cancel) Then
Return
End If
Exit Sub
End Sub
Private Sub cmdCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCopy.Click
''''My.Computer.FileSystem.CreateDirectory(lblTo.T ext & "\" &
lblFrom.Text)"""" Does not work
My.Computer.FileSystem.CopyDirectory(lblFrom.Text, lblTo.Text, _
FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)
Exit Sub
I have added this line
My.Computer.FileSystem.CreateDirectory(lblTo.Text & "\" & lblFrom.Text)
Does not except this. In VB6 I could create a directory with from "\" to.
How do you create a directory, when selection is made.
--
Thanks in advance
bob
Imports System.IO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Not Directory.Exists(Path.Combine(Application.StartupP ath,
"test_dir")) Then _
Directory.CreateDirectory(Path.Combine(Application .StartupPath,
"test_dir"))
End Sub

if you run it in the vs ide, in your bin\debug folder you should find the
test_dir subfolder.
if you run the exe, the subfolder should be in the exe's path.
i just had a look at path combine, looks rather powerful.
btw, i'm also used to classic vb :)

hth, ZC

Jan 6 '08 #3
That would work, if I now the Directory Name that is being copied.

As I stated, It is selected from the FolderBrower1.

I am able to get the complete path, but not just the selected Directory
Name.

Thanks away for the sample.
I will keep it if I ever have the need to hardcode a copy to!

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:1C**********************************@microsof t.com...
Robert,

I first will try you to learn how to fish and then give you the fish.

If you test this like you do and it does not work, then simplify your
problem, in this case by instead using a string instead of a variable you
see direct the problem.

My.Computer.FileSystem.CreateDirectory("C:\Robert" )

I tried this and it created a folder on Drive C Robert.

As I already expected (but I seldom use the My Class) does it show direct
the problem for you.

Cor



"Robert" <ro****@nowhere.comschreef in bericht
news:en**************@TK2MSFTNGP02.phx.gbl...
>Greetings
New to Visual Studio 2008.
Always us VB6.0 SP5.

I am trying to copy files from A to B.
I select a directory, and copy files. Works ok, but it does not create
the directory first.

snippet.
Private Sub cmdTo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDialog1

.ShowNewFolderButton = True

.Description = "Select the Location for Files to be copied to."

.RootFolder = Environment.SpecialFolder.Desktop

End With

' If a file is not opened, then set the initial directory to the

' FolderBrowserDialog.SelectedPath value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDialog1.ShowDialog()

' OK button was pressed.

If (result = DialogResult.OK) Then

lblTo.Text = FolderBrowserDialog1.SelectedPath

' Cancel button was pressed.

ElseIf (result = DialogResult.Cancel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCopy.Click

''''My.Computer.FileSystem.CreateDirectory(lblTo. Text & "\" &
lblFrom.Text)"""" Does not work

My.Computer.FileSystem.CopyDirectory(lblFrom.Text , lblTo.Text, _

FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)

Exit Sub

I have added this line

My.Computer.FileSystem.CreateDirectory(lblTo.Te xt & "\" & lblFrom.Text)

Does not except this. In VB6 I could create a directory with from "\" to.

How do you create a directory, when selection is made.
--
Thanks in advance
bob
ro******@mountaincable.net

Jan 6 '08 #4
In article <uo**************@TK2MSFTNGP02.phx.gbl>,
Robert <ro****@nowhere.comwrote:
That would work, if I now the Directory Name that is being copied.

As I stated, It is selected from the FolderBrower1.

I am able to get the complete path, but not just the selected Directory
Name.

Thanks away for the sample.
I will keep it if I ever have the need to hardcode a copy to!
Cor's code wasn't just for when you have a hardcoded path.

He just simplified the code to make it more clear what was happening.
If you use a variable in place of the hard coded string, and it doesn't
work, then there's only one answer -- your variable doesn't contain the
right string.

--
J.B. Moreno
Jan 8 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Cirene | last post by:
I used to use the Web Deployment Project with my VS2005 projects. Now I've fully upgraded to VS2008. Do I have to download a new version of the Web Deployment Project? If so where can I find...
20
by: Iouri | last post by:
Hi everybody, We are currently using VS2003 and now we are in the porcess of upgrading to the next Visual Studio version. Does somebody have a real life experience with VS2008? My boss wants to...
2
by: Academia | last post by:
I have vs2005 installed on the System disk and vs2008 installed on a different disk. I want to remove VS2005. I read one time about some problem with uninstalling vs2005 after vs2008 is...
0
by: ker_01 | last post by:
I received a copy of VS2008 Standard Edition at a recent MS launch event. I need to test some code for MS Office (Excel) and also update a program I wrote in VS2003 for a mobile device (still to...
2
by: cmrchs | last post by:
Hello, I installed Visual Studio 2008 last week, created a web project and could run it. I had to deinstall it for some problems I had, installed it again, try to create a new web-project but...
8
by: Frank Hauptlorenz | last post by:
Hello out there, I changed an existing and good working webservice from an wsHttpBinding to an NetTcpBinding. This is working (after trying some time) and has real a better performance! But...
4
by: BillE | last post by:
I have found articles on line about using word interop for spell checking with visual studio applications. Most of the articles are several years old, though - VS2003, maybe 2005. I couldn't...
3
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, There is a fatal error while installing VS2008 SP1 on Vista 64bit Business edition. The last line of error log is Installation failed with error code: (0x80070643) I tried to...
1
by: Henri.Chinasque | last post by:
Hi all, In VS2008 when I want to add a new assembly to a solution, Visual Studio is, by default, creating a new directory with the same name as the assembly. In previous versions of Visual...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.