|
"The only advantage VB has over some other languages is that it's built into the VB runtime"
Not sure how to quote, but the above says what I mean.
You know, I know, advanced programmers know that behind the scenes, a lot is going on (although, if the compiler has any sense it will be reduced to a "REP MOVSD" command in the end, which is very quick in small data situations).
"It's mearly creating a new one using a very expensive process"
The point I am trying to make is that in VB, there are commands that appear to resize an array. How this is done, to an average user, doesn't matter. I mean, if we were all looking for the "least expensive" ways of doing stuff, we would do most stuff in raw assembler. Sure, it will take more time to develop, but code costs running times would be reduced.
I am not meaning to start any arguments here, all I am saying is that the dimentions of an array can be changed. There are many more, optimal ways of achiving the same thing... but increasing an array using "redim" is cheaper, in terms of man hours, than developing a proper linked list. VB does hide all the inefficiences of the procedure, but to the end user, the array has been resized
|
|
|
|
|
Jasey9 wrote: but to the end user, the array has been resized
More properly, the end user gets the illusion of a array resized array.
Talking intelligently about the process, as you've no doubt have found in this thread, requires that you understand and use specific descriptions of processes. Even though VB, regretably, hides the true inner workings of such a function, this does NOT relieve the programmer from understanding what is truely going on behind the scenes. This is the one drawback to VB that causes the C, C++, C#, (insert flavor here) programmers to belittle VB programmers, saying that they don't know what they're doing.
|
|
|
|
|
Hello every...
I have a VB 2005 application (Express Edition), which i had installed at some place
I did a small bug fix and now went to install at a new place (Used ClickOnce deployment to generate Setup File)
I got this error
"Application validation Dose not succeed. Unable To continue"
On reading the details is got
"Reference in the manifest does not match the identity of the downloaded assembly"
Can any one help me out with this
Regards
Nishkarsh
|
|
|
|
|
|
Thanks for the links...
I was able to do install by deploying the solution again...
Can you plz explain me what exactly is "obfuscation" which ppl are talnkin about...
Is is safe to assume that "ClickOnce in Visual Studio 2005" is having some issue and we have to always deploy the solution twice...
Regards
Nishkarsh
|
|
|
|
|
Hi,
I'm pretty new to the forum and to VB.Net 2008
I use the express version at the moment and try to copy over files and folders from a userprofile within windows XP.
How do I skip the hidden files and folders and/or files that are in use?
I get an exeption everytime it finds something I don't have permission to.
Any idea's?
here is my code so far:
Imports System.IO
Public Class frmProfileCopier
Dim SourcePath As String, DestPath As String, ExactPath As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
SourcePath = "C:\Documents and Settings\" & tbUserName.Text & "\"
ExactPath = "UserData\" & tbUserName.Text & "\"
DestPath = fbdDestDrive.SelectedPath & "\" & ExactPath
CopyDirectory(SourcePath, DestPath)
End
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
End
End Sub
Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _
ByVal bQuiet As Boolean = False) As Boolean
If Not Directory.Exists(Src) Then
Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")
End If
If Directory.Exists(Dest) AndAlso Not bQuiet Then
If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _
"If you continue, any files with the same name will be overwritten", _
"Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function
End If
'add Directory Seperator Character (\) for the string concatenation shown later
If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then
Dest += Path.DirectorySeparatorChar
End If
If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest)
Dim Files As String()
Files = Directory.GetFileSystemEntries(Src)
Dim element As String
For Each element In Files
If Directory.Exists(element) Then
'if the current FileSystemEntry is a directory,
'call this function recursively
CopyDirectory(element, Dest & Path.GetFileName(element), True)
Else
'the current FileSystemEntry is a file so just copy it
File.Copy(element, Dest & Path.GetFileName(element), True)
End If
Next
Return True
End Function
Private Sub btnDestDrive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDestDrive.Click
fbdDestDrive.ShowDialog()
Label1.Text = fbdDestDrive.SelectedPath & "UserData\" & tbUserName.Text & "\"
End Sub
End Class
I get an exeption on the line with :
File.Copy(element, Dest & Path.GetFileName(element), True)
Also my label1 doesn't work when I use ExactPath instead of the "UserData\" & tbUserName.Text & "\"
Greetzzz,
CornElvis
www.jackied.nl
|
|
|
|
|
You can check to see if a file is marked as hidden using FileInfo . See How to: Determine if a File is Hidden in Visual Basic[^].
To handle the error on files that are currently in use and cannot be copied, I would wrap the File.Copy line in a Try...Catch block and in the Catch part I'd save those files to a log just so you can see which files were not copied.
|
|
|
|
|
thanks, I'm going to try that and come back to tell if it works or not.
Update:
I tried multiple things, but I get a permissions issue with I file I guess is either read only or in use.
How do I skip the hidden folders, because I think then everything is sorted for this purpose, although I might want to copy the Application Data folder as well.
Maybe it's better to skip the files it can't copy and then write them to a text file as you said, but I can't seem to fit the code in (I'm a rookie remember... )
Can you tell me how to do this and when it finds one it needs to jump to the next file, because then I'm done with this part and I can try to build the progress bar in....
Let me know please
Greetzzz,
CornElvis
www.jackied.nl
modified on Thursday, July 10, 2008 10:20 AM
|
|
|
|
|
|
OK, I read that and I don't think it's just because it's hidden or read only it fails, the file are in use....., so I want to exclude files that are in use and jump to the next one.
Do you have a link to do that, because I searched the web, but couldn't find it or I am thinking the wrong way around again.
thanks for the link btw
Greetzzz,
CornElvis
www.jackied.nl
|
|
|
|
|
No, I don't think there is a way to determine if a file is in use given its filename. That's where I would wrap the File.Copy line in a Try Catch.
Dim FileName As String = "filetocopy"
Try
File.Copy(FileName, FileName & ".copy")
Catch ex As Exception
My.Computer.FileSystem.WriteAllText("c:\log.txt", FileName & " - " & ex.Message, True)
End Try
|
|
|
|
|
Hi,
you can not write code that assures you a file is not in use; by the time the code comes to a
conclusion, the situation may have changed. So the only thing to do is give it a try (and a
try-catch construct).
|
|
|
|
|
OK fixed, thanks for the help.
It's now writing the not copied files to a log file and caries on with the process.
here is my code at the moment:
Imports System.IO
Imports System.Security.Permissions
Public Class frmProfileCopier
Dim SourcePath As String, DestPath As String, ExactPath As String
Dim attributeReader As System.IO.FileAttributes
Dim infoReader As System.IO.FileInfo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
SourcePath = "C:\Documents and Settings\" & tbUserName.Text & "\"
ExactPath = "UserData\" & tbUserName.Text & "\"
DestPath = fbdDestDrive.SelectedPath & "\" & ExactPath
CopyDirectory(SourcePath, DestPath)
MessageBox.Show("copy done. Please see the exclusions.log for files that couldn't be copied", "Profile Copier")
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
End
End Sub
Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _
ByVal bQuiet As Boolean = False) As Boolean
Try
If Not Directory.Exists(Src) Then
Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")
End If
If Directory.Exists(Dest) AndAlso Not bQuiet Then
If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _
"If you continue, any files with the same name will be overwritten", _
"Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function
End If
'add Directory Seperator Character (\) for the string concatenation shown later
If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then
Dest += Path.DirectorySeparatorChar
End If
If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest)
Dim Files As String()
Files = Directory.GetFileSystemEntries(Src)
Dim element As String
For Each element In Files
If Directory.Exists(element) Then
'if the current FileSystemEntry is a directory,
'call this function recursively
CopyDirectory(element, Dest & Path.GetFileName(element), True)
Else
File.Copy(element, Dest & Path.GetFileName(element), True)
End If
Next
Catch ex As Exception
Dim writer As New StreamWriter(Label1.Text & "exclusions.log", True, System.Text.Encoding.ASCII)
writer.WriteLine(ex.Message)
writer.Close()
End Try
Return True
End Function
Private Sub btnDestDrive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDestDrive.Click
fbdDestDrive.ShowDialog()
Label1.Text = fbdDestDrive.SelectedPath & "UserData\" & tbUserName.Text & "\"
End Sub
End Class
thanks again!
Greetzzz,
CornElvis
www.jackied.nl
|
|
|
|
|
to all, i just want to ask, how i supposed to draw a map/ road map in vb 2008?
any code related to this?
please kindly help me,
thanks
|
|
|
|
|
|
thanks for your information. hm, can i did a simulation using vb 2008?
|
|
|
|
|
Hi
I'm trying to open an external file, either a .pdf or .doc programmatically from VB. It seems that VB gets confused when there is a space character in the filename or path string.
The following works perfectly:
Process.Start ("acrord32", "C:\Manuals\UserManual.pdf")
and also
Process.Start ("C:\Program Files\Adobe\Reader 8.0\Reader\acrord32 " , "C:\Manuals\UserManual.pdf")
However, the following gives an error message that it cannot find the file.
Process.Start ("acrord32", "C:\Manuals\User Manual.pdf")
I've experimented a bit with multiple scenarios, including trying to open a file in word. It seems that VB accepts a path with a space character in starting a process (e.g. Adobe Reader), however it gets confused when sending the path and filename of the external file to open. In particular, when trying to open a word file, the filename is truncated at the point of the space character, e.g. the "User Manual.doc" becomes "User.doc". I've tried multiple walkarounds such as using %20, [ ], _11, etc without effect.
Any help appreciated...
|
|
|
|
|
Try double quoting the file name. The quotes in your code are not passed on, so you end up with C:\Manuals\User Manual.pdf rather than "C:\Manuals\User Manual.pdf" - if you see what I mean.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I've tried double-quoting but doesn't work in VB.
I've solved my problem with the following reply. But thanks for the interest...
Aris
|
|
|
|
|
Roullakis wrote: I've tried double-quoting but doesn't work in VB.
Meaning that you don't know how to do it...
Process.Start ("C:\Program Files\Adobe\Reader 8.0\Reader\acrord32 " , """C:\Manuals\UserManual.pdf""")
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Roullakis wrote: I've solved my problem with the following reply.
That was what I was trying to explain - obviously not very well!
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Obviously not. I thought that you were trying to explain what I showed...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
For opening .pdf or .doc file you do not need to specify any application name, as your system should be able to automatically detect application which is registered to open these file types.
Use of a simple line as following will work for you –
System.Diagnostics.Process.Start("C:\Manuals\User Manual.pdf")
Note that above mentioned syntax will work even if file name has got spaces within it.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Thanks Dave, that works
|
|
|
|
|
Dear All,
Which is the best tool to develop an CHM model help program, which will take data from a backend database and display in a manner like history of business discussion among a group of personnels.
there should be some display picture for each personnel and their comment would be come as text, each personnels comment will be separated by some lines.
you could do the same using a picture box, or datagridview, or by a richtext box. but i'm bit confused which one would be the best or any other control is available in Vb.Net ?
your suggestions are appericable
Warun
|
|
|
|
|