|
Se the post a few lines down entitled:
" Converting from a byte array to a string?"
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Im looking for the code to copy a complete folder with its entire contens to a target folder. I'm looking for this quite a while but i was unable to find it. Can anyone help me?
Thanks, Zaegra
--Zaegra--
|
|
|
|
|
Try this. It is a two step process.
1. Create your destination directory with the same name as your source directory.
2. Get all of the files in your source directory and copy it over to your newly created destination directory.
* Note: You should prompt the user that destination directory already exists and if it does, give them an option to overwrite it. If not, it will overwrite automatically. Also, you should prompt the user that the file exist that you are about to overwrite. I just bypass existing files. You might have to perform some other types of error handling, but fundamentally, everything you need is there.
Good Luck
Public Shared Sub CopyEntireDirectory(ByVal SourceDir As String, ByVal DestinationDir As String)
'Create Directory
Directory.CreateDirectory(DestinationDir)
'Declare a variable to recieve file name
Dim FileName As String
'Iterate through source directory
For Each FileName In Directory.GetFiles(SourceDir)
'Copy file with each iteration as long as the file does not exist
If File.Exists(DestinationDir & GetFileName(FileName)) = False Then
File.Copy(FileName, DestinationDir & GetFileName(FileName))
End If
Next
End Sub
Tyquaun
-- modified at 22:54 Thursday 27th July, 2006
|
|
|
|
|
Now hope it works, thanks!
--Zaegra--
|
|
|
|
|
Oh yes, one more question: does this copy the sub-folder in a directory to?? Should i try doing that with your code and by getting the names of each sub-folder? Thanks again, Zaegra
--Zaegra--
|
|
|
|
|
Yes. Get the name of each sub-folder and copy it over. If you are going to get nested folders(a sub-folder of a sub-folder) than it is going to get pretty complicated. Is that something you want to do?
|
|
|
|
|
Ehrm.. Im afraid so.. Because im making a program that can copy files and complete(!) folders to a target directory. But that should mean that.. i have to all names of all sub-folders in every folder? Thats going to be a lot of work, isn't there something more handy? If not, im going to try this and maybe send you the program if its ready?
Thanks Tyquan
--Zaegra--
|
|
|
|
|
Hey sorry it took so long to get back to you, but i have been busy. Here you go. This will copy directories recursively. Just replace the CopyEntireDirectory method I gave you with this:
Public Shared Sub CopyEntireDirectory(ByVal SourceDir As String, ByVal DestinationDir As String)
'Create Directory
Directory.CreateDirectory(DestinationDir)
'Declare a variable to recieve file name
Dim FileName As String
'Iterate through source directory
For Each FileName In Directory.GetFiles(SourceDir)
'Copy file with each iteration as long as the file does not exist
If File.Exists(DestinationDir & GetFileName(FileName)) = False Then
File.Copy(FileName, DestinationDir & GetFileName(FileName))
End If
Next
'Create directory recursively
Dim SubDirectory As String
For Each SubDirectory In Directory.GetDirectories(SourceDir)
If Not Directory.Exists(DestinationDir & GetFileName(SubDirectory)) Then
CopyEntireDirectory(SubDirectory, DestinationDir & "\" & GetFileName(SubDirectory) & "\")
End If
Next
End Sub
Tyquaun Hunter
|
|
|
|
|
Thanks Tyquan ! You've been a great help, thanks!
--Zaegra--
|
|
|
|
|
Hi,
i really need your help in this..
can i bind a data set in an html table not a datagrid? and how can i do so..i need examples.
i've created a data adapter, data set, and a data reader, after that i tried to bind the the data in the html table but it's now working
Thanks
|
|
|
|
|
Why would you want bind to an HTML table and not a datagrid?
|
|
|
|
|
Because i think the html table is more flexibe than a datagrid.
i want to view my results like this:
First Name DataBind
Last Name DataBind
Address DataBind
(This is for one person)
not like this:
Column1 Column2 Column3
DataBind DataBind DataBind
DataBind DataBind DataBind
DataBind DataBind DataBind
(This for more than one person)
do you think i can do this with a datagrid?
|
|
|
|
|
Yes, but you have to construct the datagrid yourself and not use the control that visual studio provides for you. Also, which probably makes more sense, is if you use a datareader and build the table yourself. This is much more efficient than a datagrid.
Tyquaun
|
|
|
|
|
You can use DataList for this purpose
as
and provide your data to be shown in ItemTemplate tag in html ..
like this
<asp:Lable ID="lblName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"FirstName")%>' runat="server" />
put it in ItemTemplate of DataList
R A M
|
|
|
|
|
Heloo i want ro make a radix sort for a ashort project. i want to get the input from the user and also it will be in integer in visual basic
if possible give me guidence .. or send the radix sort code
faisal manzoor
|
|
|
|
|
If you would have Googled for "radix sort"[^], you would have found that the first hit is a good explanation of the algorithm, and contains sample implementations.
---
b { font-weight: normal; }
|
|
|
|
|
How can I do a calculation based on a formula entered via text box? Basically, I'm reading the result of a Analog to Digital Converter reading (ADC_Value)via RS232.
Examples of different formulas that need to be applied:
(LM60 Temperature) Result = 6.25/(ADC_Value - 424)
(LM50 Temperature) Result = 10/(ADC_Value - 500)
(A/D Voltage) Result = ADC_Value/1023 * 5
Basically I'd like to save the different formulas in a Database, each with a short description, and then load these into a combo. Then request the ADC_Value via RS232, take that value and manipulate it according to the combo selection, and display the result.
The reason I don't want to hard code the formulas is that should use a defferent sensor on the A/D Converter, then I would have to manually add this to the application.
Is there some sort of control that can build an expression from a string?
|
|
|
|
|
I don't know of any control that does that in VB.NET but I think you may have answered your own question...
RichardBerry wrote: Basically I'd like to save the different formulas in a Database, each with a short description, and then load these into a combo. Then request the ADC_Value via RS232, take that value and manipulate it according to the combo selection, and display the result.
That shouldn't be too hard.
After doing that you could create your own class that takes those values and performs the calculations. Think of all the variables you'll be using in the calculation and use those as arguments in functions that return the value. Those same varibles could be saved in your database and called, changed, inserted, deleted, whatever.
Just an idea. Or have i misunderstood you?
|
|
|
|
|
Mmm I'm not really understanding you. Take this as an example:
Dim ADC_Value as Integer
Dim Result as Double
Dim TextBoxFormula as String
ADC_Value = GetADC
Lets say the TextBox contains: "6.25/(ADC_Value - 424)"
How can I change the above STRING into an experession that can be evaluated.
i.e. Result = 6.25/(ADC_Value - 424)
Function GetADC() as integer
Code to get ADC Value
Return Value
End Sub
|
|
|
|
|
Ah, I see now. I assumed that the textbox would only hold the value "6.25" and a combobox or another control would hold the ADC_Value (is the 424 a constant?). Then what you would have is something like...
'an event to call the function
Private Sub btnCalc_Click.....
'get the ADC value and add it to a label
Label1.Text = CStr(GetADC(Textbox1.Text, cboADC.Text)
End Sub
'the variables used in this function could be stored in a database
' and called when necessary. the "Value" argument is the 6.25 from the
' textbox.
Public Function GetADC(ByVal Value as Double, ByVal ADC_Value as Double) As Double
Dim dblADC As Double 'variable to return
dblADC = Value * (ADC_Value - 424) 'do the calculation
Return dblADC 'retun the result
End Function
If the 424 is also a variable, it could also be stored in a database and added as an additional argument to your function, or you could create an overloaded function if it's not always required.
Using this kind of method your users won't have to remember the formula as you build it for them. All they'd have to change is the value in the textbox which would make it far more user-friendly. Also, you could then validate in code that the value supplied in the textbox (6.25 in your example) was in fact a valid datatype which will prevent your app from breaking and generally improving it's stability. See where I'm going with this?
At the end of the day tho, it's your project and your clients. I'm only trying to give you another perspective on how to tackle it. From my approach, the class you'd write would be more of a "Formula Engine" which builds the formulae that users would need without them having to remember it, flexible enough to accomodate variations on the formula (using overloads, possibly) but still robust enough that your results are reliable.
There are a couple of ways you could go about this... interesting. Thanks.
|
|
|
|
|
Thanks for your input. I think I've overcomplicated things a bit. If I look at the formulas I'm using:
ADC_Value = (6.25/Temperature) + 424
I read the ADC_Value, and want to calculate the Temperature. But the above equation is a linear equation in the form y= ax + b, so all I really need is two text boxes, one for 'a' and one for 'b', y is the value returned via RS232 and I can solve for 'x' (or Temperature in this case). I can also then add the required validation on the textboxes as you suggest.
|
|
|
|
|
So your problem is solved? yes? no?
|
|
|
|
|
Yes thanks my problem is solved
|
|
|
|
|