473,748 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDi alog1

..ShowNewFolder Button = True

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

..RootFolder = Environment.Spe cialFolder.Desk top

End With

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

' FolderBrowserDi alog.SelectedPa th value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDi alog1.ShowDialo g()

' OK button was pressed.

If (result = DialogResult.OK ) Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

' Cancel button was pressed.

ElseIf (result = DialogResult.Ca ncel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdCopy.Click

''''My.Computer .FileSystem.Cre ateDirectory(lb lTo.Text & "\" &
lblFrom.Text)"" "" Does not work

My.Computer.Fil eSystem.CopyDir ectory(lblFrom. Text, lblTo.Text, _

FileIO.UIOption .AllDialogs, FileIO.UICancel Option.DoNothin g)

Exit Sub

I have added this line

My.Computer.Fil eSystem.CreateD irectory(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******@mounta incable.net
Jan 5 '08 #1
4 2824
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.Fil eSystem.CreateD irectory("C:\Ro bert")

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******** ******@TK2MSFTN GP02.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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDi alog1

.ShowNewFolderB utton = True

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

.RootFolder = Environment.Spe cialFolder.Desk top

End With

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

' FolderBrowserDi alog.SelectedPa th value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDi alog1.ShowDialo g()

' OK button was pressed.

If (result = DialogResult.OK ) Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

' Cancel button was pressed.

ElseIf (result = DialogResult.Ca ncel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdCopy.Click

''''My.Computer .FileSystem.Cre ateDirectory(lb lTo.Text & "\" &
lblFrom.Text)"" "" Does not work

My.Computer.Fil eSystem.CopyDir ectory(lblFrom. Text, lblTo.Text, _

FileIO.UIOption .AllDialogs, FileIO.UICancel Option.DoNothin g)

Exit Sub

I have added this line

My.Computer.Fil eSystem.CreateD irectory(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******@mounta incable.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(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTo.Click
'Open the Dialog Box to Copy Files.
With FolderBrowserDi alog1
.ShowNewFolderB utton = True
.Description = "Select the Location for Files to be copied to."
.RootFolder = Environment.Spe cialFolder.Desk top
End With
' If a file is not opened, then set the initial directory to the
' FolderBrowserDi alog.SelectedPa th value.
If lblTo.Text = "" Then
lblTo.Text = FolderBrowserDi alog1.SelectedP ath
lblTo.Text = Nothing
End If
' Display the openFile dialog.
Dim result As DialogResult = FolderBrowserDi alog1.ShowDialo g()
' OK button was pressed.
If (result = DialogResult.OK ) Then
lblTo.Text = FolderBrowserDi alog1.SelectedP ath
' Cancel button was pressed.
ElseIf (result = DialogResult.Ca ncel) Then
Return
End If
Exit Sub
End Sub
Private Sub cmdCopy_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdCopy.Click
''''My.Computer .FileSystem.Cre ateDirectory(lb lTo.Text & "\" &
lblFrom.Text)"" "" Does not work
My.Computer.Fil eSystem.CopyDir ectory(lblFrom. Text, lblTo.Text, _
FileIO.UIOption .AllDialogs, FileIO.UICancel Option.DoNothin g)
Exit Sub
I have added this line
My.Computer.Fil eSystem.CreateD irectory(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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
If Not Directory.Exist s(Path.Combine( Application.Sta rtupPath,
"test_dir") ) Then _
Directory.Creat eDirectory(Path .Combine(Applic ation.StartupPa th,
"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******** *************** ***********@mic rosoft.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.Fil eSystem.CreateD irectory("C:\Ro bert")

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******** ******@TK2MSFTN GP02.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(ByV al sender As System.Object, ByVal e As
System.EventAr gs) Handles cmdTo.Click

'Open the Dialog Box to Copy Files.

With FolderBrowserDi alog1

.ShowNewFolder Button = True

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

.RootFolder = Environment.Spe cialFolder.Desk top

End With

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

' FolderBrowserDi alog.SelectedPa th value.

If lblTo.Text = "" Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

lblTo.Text = Nothing

End If

' Display the openFile dialog.

Dim result As DialogResult = FolderBrowserDi alog1.ShowDialo g()

' OK button was pressed.

If (result = DialogResult.OK ) Then

lblTo.Text = FolderBrowserDi alog1.SelectedP ath

' Cancel button was pressed.

ElseIf (result = DialogResult.Ca ncel) Then

Return

End If

Exit Sub

End Sub

Private Sub cmdCopy_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles cmdCopy.Click

''''My.Compute r.FileSystem.Cr eateDirectory(l blTo.Text & "\" &
lblFrom.Text)" """ Does not work

My.Computer.Fi leSystem.CopyDi rectory(lblFrom .Text, lblTo.Text, _

FileIO.UIOptio n.AllDialogs, FileIO.UICancel Option.DoNothin g)

Exit Sub

I have added this line

My.Computer.Fi leSystem.Create Directory(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******@mounta incable.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
5985
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 it? If not, how do I have to change my deployment strategy? Thanks!
20
2889
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 go with VS2005 and I am trying to convince to buy VS2008. Can somebody provide links to compare 2 products in terms of how stable they are. I do not need VS2008 new features, I need to prove to my management that VS2008 is a stable product. TIA
2
2443
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 installed but can't find the site now. Is there a problem? Would reinstalling vs2008 fix any problem that may occur because of uninstalling vs2005.
0
1319
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 run on the same, ancient mobile device). I did a search for VS2008 upgrades, but the search returned an overwhelming number of upgrades from earlier versions of VS to VS2008, rather than any upgrade options from 2008 standard to 2008 pro. ...
2
1546
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 now VS2008 comes up with the message "unable to create website... you must install IIS, ASP.NET, ..." I check in Control Panel\Installed programs and see that the WebPart
8
2147
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 one thing is strange: when I'm now actualising the web reference from within VS2008, VS2008 creates a 2nd endpoint config in my app.conf. The endpoint is exactly the same as the existing but the name and
4
2968
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 find anything for VS2008. Are there any new improvements in spell checking with VS2008? Thanks Bill
3
5804
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 uninstall Silverlight first (which is described in some blogs) and install .NET framework 3.5 SP1 manually but still failed. My VS2008 is Team Suit for developer and Vista SP1 is also installed.
1
3203
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 Studio this functionality could be disabled, in this version I can't seem to get it to stop doing this. Any ideas? thanks, HC
0
8995
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6798
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.