|
well, unfortunately for me... but, some clients still uses legacy apps. especially vb apps. so what can i complain about? This is what they require.. i have given them option to upgrade, well, they will have to think about it...
but anyways, thanks for the the sample code.., i got the project running over the LAN, but for XP only.. i advised the owner of the system not to transfer the system to win7 OS.. or compatibility issues may arise..
[RESOLVED]
|
|
|
|
|
Thanks in advance,
I am using "System.Net" to download files from the FTP , how can i get the Download time of a file , any suggestions ?
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
modified on Friday, March 25, 2011 7:23 AM
|
|
|
|
|
S0FTDEV wrote: any suggestions ?
yes, please clarify your question.
What is "download time"? is it the duration of the download? is it the current time while the download starts/ends? or what?
S0FTDEV wrote: how can i get
who is "i"? is it the server? is it the client?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
There is no property to get this value. You have to know how big the file is, download some of the data, measure how long that takes, compute the remaining time based on that, download more of the data, measure how long that took, ... rinse and repeat.
|
|
|
|
|
If you mean "How long will it take to download this file" then it is impossible to say.
There are so many variables that chaos theory reigns!
In fact it is a matter bone of contention.
However you can do a rough reckoner if you know the download speed of the user, his type of connection etc.
There are apps that can give estimated times for different file sizes or connections speeds, a simple google search will reveal them to you.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
you can try this:
Download_time=(HttpWebResponse.ContentLength)/(your_connection_speed);
as for example: A file size(ContentLength) is 1,048,576 bytes(1 MB) and you connection speed is 512KB then the
Download_time=(1,048,576/524,288) = 2 Seconds.
|
|
|
|
|
Thanks all for the replies , i had solved it. by using FTP method {content length}
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|
|
I have several text boxes on my form each with the same right-click menu. Some of the items it has are cut, copy, paste, spell checking, and auto text entries. I have everything working except for the auto-text entries because I can not figure out how to get which text box the menu is attached to. The code I have right now (which is working) is when the menu is opened to determine which items should be enabled (for example if there is no text on the clipboard the paste menu item should be disabled):
Private Sub RightClickContextMenuStrip_Opened(ByVal sender As Object, ByVal e As System.EventArgs) Handles RightClickContextMenuStrip.Opened
Dim cms As ContextMenuStrip
Dim TempTextBox As TextBox
cms = CType(sender, ContextMenuStrip)
If TypeOf (cms.SourceControl) Is TextBox Then
TempTextBox = CType(cms.SourceControl, TextBox)
If Not String.IsNullOrEmpty(TempTextBox.SelectedText) AndAlso TempTextBox.ReadOnly = False Then
mnuCut.Enabled = True
mnuCopy.Enabled = True
Else
mnuCut.Enabled = False
mnuCopy.Enabled = False
End If
If Clipboard.ContainsText Then
mnuPaste.Enabled = True
Else
mnuPaste.Enabled = False
End If
If My.Settings.AutoText Is Nothing OrElse My.Settings.AutoText.Count < 1 Then
mnuRightClickAutoText.Enabled = False
Else
mnuRightClickAutoText.DropDownItems.Clear()
For Each item As String In My.Settings.AutoText
Dim AutoTextItem As ToolStripItem
AutoTextItem = mnuRightClickAutoText.DropDownItems.Add(item)
AddHandler AutoTextItem.Click, AddressOf AutoText_Click
Next
End If
End If
End Sub
Now I have a function that captures which auto text sub-menu item is clicked, but I can't figure out how to find out which text box the menu is attached to. Here is my code thus far:
Private Sub AutoText_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cms As ContextMenuStrip
Dim dpm As ToolStripDropDownMenu
Dim Item As ToolStripItem
Dim TempTextBox As TextBox
Dim selectionIndex As Integer
Item = CType(sender, ToolStripItem)
cms = CType(Item.OwnerItem.Owner, ContextMenuStrip)
If TypeOf (cms.SourceControl) Is TextBox Then
TempTextBox = CType(cms.SourceControl, TextBox)
selectionIndex = TempTextBox.SelectionStart
TempTextBox.Text = TempTextBox.Text.Insert(selectionIndex, Item.Text)
TempTextBox.SelectionStart = selectionIndex + Item.Text.Length
End If
End Sub
However with this code the cms.SourceControl is nothing. The menu is set up like this
Cut
Copy
Paste
------
AutoText -> Item1, Item2, Item3
------
Basic Filter
Advanced Filter
I'm capturing the click events on Item1, Item2, etc. but can't figure out what text box they go to. How do I get the source control in this circumstance. Thanks in advanced for any help.
|
|
|
|
|
IMO this has been asked and answered last week, see here[^].
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Actually what I found out is in my situation, with a dropdownmenuitem, there is a bug in the framework that actually clears the sourcecontrol property. I need to save the sourcecontrol property on the contextmenuopened event. Thanks anyways.
|
|
|
|
|
Hi.
I'm trying to encrypt text using advapi32.dll function CryptEncrypt, RC4.
Before encrypting, y call CryptAcquireContext and CryptCreateHash, but this last one returns me zero. Err.LastDllError says it is an 87, so invalid parameter, but can't figure out where is the error.
Private Const ALG_CLASS_HASH As Long = 32768 ' (4 < 13)
Private Const ALG_TYPE_ANY As Long = 0
Private Const ALG_SID_MD5 As Long = 3
Private Const CALG_MD5 As Long = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5
....
Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" _
(ByRef phProv As Long, _
ByVal pszContainer As String, _
ByVal pszProvider As String, _
ByVal dwProvType As Long, _
ByVal dwFlags As Long) As Long
Private Declare Function CryptCreateHash Lib "advapi32.dll" _
(ByVal hProv As Long, _
ByVal algID As Long, _
ByVal hKey As Long, _
ByVal dwFlags As Long, _
ByRef phHash As Long) As Long
...
'CryptAcquireContext works fine
lResult = CryptAcquireContext(m_lProvider, sKeyRoot, CRYPTO_PROVIDER, PROV_RSA_FULL, 0)
If lResult = 0 Then
lResult = CryptAcquireContext(m_lProvider, sKeyRoot, CRYPTO_PROVIDER, PROV_RSA_FULL, CRYPT_NEWKEYSET)
If lResult = 0 Then
MsgBox(ERROR_AQUIRING_CONTEXT)
End If
End If
'Now this is where I get zero
' Create a handle to a hash object using the MD5 algorithm
lResult = CryptCreateHash(m_lProvider, CALG_MD5, 0, 0, lHash)
If lResult = 0 Then
Dim a As Long = Err.LastDllError
MsgBox(ERROR_CREATING_HASH)
Return ""
End If
Any idea what I am missing?
|
|
|
|
|
I didn't study that in any detail, however I noticed your prototype(s) is/are totally wrong; see here[^].
FWIW: if you need more information on P/Invoke, you may want to read this[^] first.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks, It's my first time calling api functions so I may be doing it totally wrong... I found that code and I was trying to make it work. At least, part of it did it.
I'll study your reference. thanks.
|
|
|
|
|
You found what appears to be VB6 code. The Long type in VB6 is a 32-bit signed integer. In VB.NET, it's a 64-bit signed integer. The two are not interchangable when P/Invoking API functions. In VB.NET, you replace the Longs with Integer.
|
|
|
|
|
yep. He also better use IntPtr for passing pointers, if Win64 is going to be used someday.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi, can we insert/update value to ms access database over network via UDP?
modified on Thursday, March 24, 2011 2:06 AM
|
|
|
|
|
Considering Access is a file-based database, with no communication server at all, it's impossible to do directly. You've have to build some kind of server component to handle all the database access over a network connection of your choice.
|
|
|
|
|
I see...
But, i was asked to develop a client-server applications using Microsoft Access. Is the only way to make connection to access database over the network,just to share the folder where my application is, and the 2nd option is using access database project (ADP) with SQL server? (sorry for my bad english, hope you'll understand)
modified on Monday, March 21, 2011 7:53 PM
|
|
|
|
|
The only way to get at an Access database without writing your own communication component is through a network share. You have to be able to map a drive to wherever the database sits. I'm not saying you HAVE to map a drive, you just have to be ABLE to map a drive to it. You can use the database without a drive letter if you can use a UNC path to get at it.
You do NOT have to use Access at all. If you have SQL Server, throwing Access in the middle just needlessly complicates your system.
|
|
|
|
|
Could you give a sample code for mapping drive without share the application folder?
|
|
|
|
|
You have no clue how Windows Networking works, do you? There is no code sample because you cannot map a drive to anything other than a shared folder.
|
|
|
|
|
Ok, thanks for your explanation.
|
|
|
|
|
How about if i build server component using vb 6 or microsoft access form? Could you give me a sample to do that?
modified on Wednesday, March 23, 2011 10:33 PM
|
|
|
|
|
No. I haven't touched VB6 in over 10 years.
I got my hands on VB.NET when .NET was a Beta and haven't looked back since.
If you have to make a server component just because you want to use Access, you're in deep trouble. Move to a database engine that supports this already, such as SQL Server, Oracle, MySQL, whatever... Access is probably the only database engine that doesn't support what you want to do, so why waste the effort on it?
|
|
|
|
|
|