|
I found this on the web a few years ago. I do not remember where.
Private Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, _
Optional ByVal Overwrite As Boolean = False)
Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath)
Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath)
' the source directory must exist, otherwise throw an exception
If SourceDir.Exists Then
' if destination SubDir's parent SubDir does not exist throw an exception
If Not DestDir.Parent.Exists Then
Throw New DirectoryNotFoundException _
("Destination directory does not exist: " + DestDir.Parent.FullName)
End If
If Not DestDir.Exists Then
DestDir.Create()
End If
' copy all the files of the current directory
Dim ChildFile As FileInfo
For Each ChildFile In SourceDir.GetFiles()
If Overwrite Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True)
Else
' if Overwrite = false, copy the file only if it does not exist
' this is done to avoid an IOException if a file already exists
' this way the other files can be copied anyway...
If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), _
False)
End If
End If
Next
' copy all the sub-directories by recursively calling this same routine
Dim SubDir As DirectoryInfo
For Each SubDir In SourceDir.GetDirectories()
CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, SubDir.Name), Overwrite)
Next
Else
Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName)
End If
End Sub
The recursive call is a bit confusing but this has copied my list of directories every night for at least two years.
Should solve your porbelm also.
RCarey
RCarey
|
|
|
|
|
Hi all,
Is it possible to create access users from Vb.net. The company I work for has an application in Access 2003 with a SQL server back end. To log in to the application you have to be a user in SQL server and a user in access with the same password. We are constantly adding new users to the application. I want to create a VB.net application that creates SQL server users and Access users in one place. I was wondering if this is possible. Any ideas or commends or code would be appreciated.
Goran
|
|
|
|
|
Goran have you tried pulling in the com object for access and playing with that, otherwise if you are just using the jet login I doubt you can add users, I could be wrong.
Regards,
Johny Rodriguez
The GDC, New York.
|
|
|
|
|
I have been trying to connect to the mdw file to insert the users but no luck there. Thanks for the idea for the com object but I still would need the VBA code. I will play with it and if I figure out anything ill post the code. Meanwhile if any one can throw any code my way I would appreciate it. Thanks Johny now I have a staring point.
Goran Djuric
|
|
|
|
|
Hi! I want to know how can i open files of any type with appropriate programs in vb.
(Say to open html with internet explorer and frm file with vb etc)
The Shell command in vb is useful in launching only EXEs. But I am not able to open files of other type.
For example my vb code should open "c:\abc\test.txt" with notepad.
Secondly I want to how long my system continues to be in idle state.The screen saver is launched only when system remains idle for a particular time.
And I need to retrieve the idle time of system using my code.How is it possible?
Pls help me. Thanks in advance.
Revathi
|
|
|
|
|
Please don't crosspost, especially posting a C# question in the VB.NET forum!
|
|
|
|
|
I have a crystal report with 3 parameters, XYZ, Version, Other and I am trying to pass values via VB.Net to this report. It is no problem passing one but any more than that, it does not seem to work. The problem is that it the last parameter holds the value and the others are blank. What am I doing wrong. This is driving me crazy. Here is my code.
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim strReportPath As String = "C:\temp\report1.rpt"
Try
'Load Crystal Report's rpt file
Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument
cr.Load(strReportPath)
''Declare the parameter related objects
Dim param1Fields As New CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim param2Fields As New CrystalDecisions.Shared.ParameterFields
Dim param2Field As New CrystalDecisions.Shared.ParameterField
Dim param2Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim param3Fields As New CrystalDecisions.Shared.ParameterFields
Dim param3Field As New CrystalDecisions.Shared.ParameterField
Dim param3Range As New CrystalDecisions.Shared.ParameterDiscreteValue
param1Field.ParameterFieldName = "XYZ"
param1Range.Value = 31000
param1Field.CurrentValues.Add(param1Range)
param1Fields.Add(param1Field)
CrystalReportViewer1.ParameterFieldInfo = param1Fields
param2Field.ParameterFieldName = "Version"
param2Range.Value = 10
param2Field.CurrentValues.Add(param2Range)
param2Fields.Add(param2Field)
CrystalReportViewer1.ParameterFieldInfo = param2Fields
param3Field.ParameterFieldName = "Other"
param3Range.Value = 44
param3Field.CurrentValues.Add(param3Range)
param3Fields.Add(param3Field)
CrystalReportViewer1.ParameterFieldInfo = param3Fields
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
CrystalReportViewer1.ReportSource = strReportPath
CrystalReportViewer1.Refresh()
'Set the CrystalReportViewer's apperance and set the ReportSource
CrystalReportViewer1.ShowRefreshButton = False
CrystalReportViewer1.ShowCloseButton = False
CrystalReportViewer1.ShowGroupTreeButton = False
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
|
|
|
|
|
Hi,
Using the Exception Management Application Block I can create new logs in the Event Viewer by placing the following in my app.config file:
<exceptionManagement mode="on">
<publisher
assembly="MyAppBlockTest"
type="MyAppBlockTest.ExceptionPublisher"
logname="My Test Log"
applicationname="Exception Management Application Block Test"
fileName="c:\errors.txt">
</publisher>
</exceptionManagement>
I am now trying to use the Enterprise Library and I don't know how to create a new log. I can only write to the default Application log. Can anyone tell me how I can do this?
Thanks very much,
dlarkin77
|
|
|
|
|
Can anyone point me in the right direction to write a ‘cluster aware service’.
I have written a service in VB.NET all works very well but my client said that the service must be cluster aware, as it will be running on a cluster of servers.
Any help would be greatly appreciated.
|
|
|
|
|
This has to be taken into account in the design of your service. It's, usually, not something you can just "bolt on" as an afterthought.
There is no native support for clustering built into the .NET Framework. You'll have to do it the old fashioned way, using the COM objects. Introducing Microsoft Cluster Service (MSCS) in the Windows Server 2003 Family[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to create a sound recorder that records voice through microphone
in 128 kbps,mono,8khz sampling rate, 16 bits per sample using VB.NET and
DirectX 8.0's DirectSound API.
Can any body help me?
If possible send me sample code at devang.mg@gmail.com
Thank you in advance..
What you think is what you get
|
|
|
|
|
Hi OLETypeAllowed
Im in the same dilema now. Did you get any answers?
10X
Alex
Alex
|
|
|
|
|
when i was trying to connect to the database there is an error occured. the erro r is:
The ConnectionString property has not been initialized.
i check it with the local window below it,the connection to database is null. what can i do?
|
|
|
|
|
Generate a new Connection and set the ConnectionString property to a usable value. If you search in the Microsoft Help for the Database Connection Class you will find an example.
So it's definitively wrong I guess.
Greetings,
Ingo
------------------------------
A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!
|
|
|
|
|
You should initialize connectionstring
|
|
|
|
|
|
if u are using WebApplication example is below
Dim SqlConnection conn As New SqlConnection;
conn = System.Configuration.ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString;
If (Not Page.IsPostBack) Then
'Do Some Codeing Here
EndIf
|
|
|
|
|
the error is :
Value of type 'System.Configuration.ConnectionStringSettingsCollection' cannot be converted to 'System.Data.SqlClient.SqlConnection'.
so?
|
|
|
|
|
Dude i am not vb programmer but maybe i can help by this
Imports System.Configuration
..
Dim ConnectionStringSettingsCollection c As New ConnectionStringSettingsCollection
Dim cc,command As String
cc=c[""urconn"].ConnectionString;
command="select * from Customers"
Dim SqlConnection scon As SqlConnection()
scon(cc)
Dim SqlCommand cmd As SqlCommand()
cmd(scommand,scon)
...
|
|
|
|
|
You have posted similar questions before. It seems to me that you really are struggling with this topic despite the help provided by others. May I respectfully suggest that you go back to basics and read up on how to interact with these objects within VB?
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
-- modified at 18:58 Thursday 2nd March, 2006
|
|
|
|
|
hi
how to access a DLL in VB?
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
VB6 Declare Statement[^]
VB.NET Declare Statement[^]
The exact details of using your particular .DLL will be up to your knowledge of that .DLL. Without any documentation on it, it's near impossible.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want to access sql server in a defferent location. I pass the connection string through a web service on the server but it gives me this exception
system.web service exceptionerror server was unable to process request. Server does not exit or access denied
-- modified at 6:25 Thursday 2nd March, 2006
|
|
|
|
|
|
what access level are you trying to access it from? if you can't get in with the sa login it's possible you're hitting the firewall at the host...?
Regards,
Johny Rodriguez
The GDC, New York.
|
|
|
|